daklib.dbconn

DB access class

@contact: Debian FTPMaster <ftpmaster@debian.org> @copyright: 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org> @copyright: 2008-2009 Mark Hymers <mhy@debian.org> @copyright: 2009, 2010 Joerg Jaspert <joerg@debian.org> @copyright: 2009 Mike O’Connor <stew@debian.org> @license: GNU General Public License version 2 or later

Functions

get_active_keyring_paths([session])

return:

list of active keyring paths

get_architecture(architecture[, session])

Returns database id for given architecture.

get_archive(archive[, session])

returns database id for given archive.

get_component(component[, session])

Returns database id for given component.

get_component_by_package_suite(package, ...)

Returns the component name of the newest binary package in suite_list or None if no package is found.

get_component_names([session])

Returns list of strings of component names.

get_dbchange(filename[, session])

returns DBChange object for given filename.

get_dscfiles([dscfile_id, source_id, ...])

Returns a list of DSCFiles which may be empty

get_fingerprint(fpr[, session])

Returns Fingerprint object for given fpr.

get_keyring(keyring[, session])

If keyring does not have an entry in the keyrings table yet, return None If keyring already has an entry, simply return the existing Keyring

get_ldap_name(entry)

get_maintainer(maintainer_id[, session])

Return the name of the maintainer behind maintainer_id or None if that maintainer_id is invalid.

get_mapped_component(component_name[, session])

get component after mappings

get_mapped_component_name(component_name)

get_new_comments(policy_queue[, package, ...])

Returns (possibly empty) list of NewComment objects for the given parameters

get_or_set_fingerprint(fpr[, session])

Returns Fingerprint object for given fpr.

get_or_set_maintainer(name[, session])

Returns Maintainer object for given maintainer name.

get_or_set_metadatakey(keyname[, session])

Returns MetadataKey object for given uidname.

get_or_set_uid(uidname[, session])

Returns uid object for given uidname.

get_override(package[, suite, component, ...])

Returns Override object for the given parameters

get_override_type(override_type[, session])

Returns OverrideType object for given override_type.

get_policy_queue(queuename[, session])

Returns PolicyQueue object for given queuename

get_priorities([session])

Returns dictionary of priority names -> id mappings

get_priority(priority[, session])

Returns Priority object for given priority name.

get_section(section[, session])

Returns Section object for given section name.

get_sections([session])

Returns dictionary of section names -> id mappings

get_source_in_suite(source, suite_name[, ...])

Returns a DBSource object for a combination of source and suite_name.

get_suite(suite[, session])

Returns Suite object for given suite name.

get_suite_architectures(suite[, skipsrc, ...])

Returns list of Architecture objects for given suite name.

get_suites_binary_in(package[, session])

Returns list of Suite objects which given package name is in

get_suites_source_in(source[, session])

Returns list of Suite objects which given source name is in

get_uid_from_fingerprint(fpr[, session])

get_version_checks(suite_name[, check, session])

has_new_comment(policy_queue, package, version)

Returns True if the given combination of package, version has a comment.

import_metadata_into_db(obj[, session])

This routine works on either DBBinary or DBSource objects and imports their metadata into the database

session_wrapper(fn)

Wrapper around common ".., session=None):" handling.

Classes

ACL()

ACLPerSource()

ACLPerSuite()

Archive(*args, **kwargs)

ArchiveFile([archive, component, file])

BinContents([file, binary])

BinaryMetadata([key, value, binary])

BuildQueue(*args, **kwargs)

Component([component_name])

DBBinary([package, source, version, ...])

DBChange(*args, **kwargs)

DBConfig(*args, **kwargs)

DBConn(*args, **kwargs)

database module init.

DBSource([source, version, maintainer, ...])

DSCFile(*args, **kwargs)

DebVersion()

ExternalOverride(*args, **kwargs)

Fingerprint([fingerprint])

Keyring(*args, **kwargs)

Maintainer([name])

MetadataKey([key])

MetadataProxy(session, query)

NewComment(*args, **kwargs)

ORMObject()

ORMObject is a base class for all ORM classes mapped by SQLalchemy.

Override([package, suite, component, ...])

OverrideType([overridetype])

PolicyQueue(*args, **kwargs)

PolicyQueueByhandFile()

PolicyQueueUpload()

PoolFile([filename, filesize, md5sum])

Priority([priority, level])

SignatureHistory()

SourceMetadata([key, value, source])

SrcContents([file, source])

SrcFormat(*args, **kwargs)

Suite([suite_name, version])

Uid([uid, name])

VersionCheck(*args, **kwargs)

class daklib.dbconn.ACL[source]
class daklib.dbconn.ACLPerSource[source]
class daklib.dbconn.ACLPerSuite[source]
class daklib.dbconn.Architecture(arch_string=None, description=None)[source]
_sa_class_manager = {'arch_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'arch_string': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'created': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'description': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'modified': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
arch_id
arch_string
created
description
modified
class daklib.dbconn.Archive(*args, **kwargs)[source]
class daklib.dbconn.ArchiveFile(archive=None, component=None, file=None)[source]
property path
class daklib.dbconn.BinContents(file=None, binary=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.BinaryMetadata(key=None, value=None, binary=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.BuildQueue(*args, **kwargs)[source]
class daklib.dbconn.Component(component_name=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.DBBinary(package=None, source=None, version=None, maintainer=None, architecture=None, poolfile=None, binarytype='deb', fingerprint=None)[source]
property arch_string: str
metadata

A descriptor that presents a read/write view of an object attribute.

property name: str
property pkid: int
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

property proxy: MetadataProxy
read_control() bytes[source]

Reads the control information from a binary.

Returns:

stanza text of the control section.

read_control_fields() TagSection[source]

Reads the control information from a binary and return as a dictionary.

Returns:

fields of the control section as a dictionary.

scan_contents() Iterable[str][source]

Yields the contents of the package. Only regular files are yielded and the path names are normalized after converting them from either utf-8 or iso8859-1 encoding. It yields the string ‘ <EMPTY PACKAGE>’ if the package does not contain any regular file.

class daklib.dbconn.DBChange(*args, **kwargs)[source]
class daklib.dbconn.DBConfig(*args, **kwargs)[source]
class daklib.dbconn.DBConn(*args, **kwargs)[source]

database module init.

__createconn()
__setupmappers()
__setuptables()
__shared_state = {}
db_meta = None
session(work_mem=0)[source]

Returns a new session object. If a work_mem parameter is provided a new transaction is started and the work_mem parameter is set for this transaction. The work_mem parameter is measured in MB. A default value will be used if the parameter is not set.

tables = ('acl', 'acl_architecture_map', 'acl_fingerprint_map', 'acl_per_source', 'acl_per_suite', 'archive', 'bin_associations', 'bin_contents', 'binaries', 'binaries_metadata', 'build_queue', 'changelogs_text', 'changes', 'component', 'component_suite', 'config', 'dsc_files', 'external_files', 'external_overrides', 'external_signature_requests', 'extra_src_references', 'files', 'files_archive_map', 'fingerprint', 'hashfile', 'keyrings', 'maintainer', 'metadata_keys', 'new_comments', 'override', 'override_type', 'policy_queue', 'policy_queue_upload', 'policy_queue_upload_binaries_map', 'policy_queue_byhand_file', 'priority', 'signature_history', 'source', 'source_metadata', 'src_associations', 'src_contents', 'src_format', 'src_uploaders', 'suite', 'suite_acl_map', 'suite_architectures', 'suite_build_queue_copy', 'suite_permission', 'suite_src_formats', 'uid', 'version_check')
tbl_architecture = Table('architecture', MetaData(), Column('created', DateTime(timezone=True), table=<architecture>, nullable=False, server_default=DefaultClause(<sqlalchemy.sql.functions.now at 0x7f79c9296bd0; now>, for_update=False)), Column('modified', DateTime(timezone=True), table=<architecture>, nullable=False, server_default=DefaultClause(<sqlalchemy.sql.functions.now at 0x7f79c9296dd0; now>, for_update=False)), Column('id', Integer(), table=<architecture>, primary_key=True, nullable=False), Column('arch_string', Text(), table=<architecture>, nullable=False), Column('description', Text(), table=<architecture>), schema=None)
views = ('bin_associations_binaries', 'changelogs', 'newest_source', 'newest_src_association', 'package_list', 'source_suite', 'src_associations_src')
class daklib.dbconn.DBSource(source=None, version=None, maintainer=None, changedby=None, poolfile=None, install_date=None, fingerprint=None)[source]
property arch_string: str
metadata

A descriptor that presents a read/write view of an object attribute.

property name: str
property pkid: int
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

property proxy: MetadataProxy
read_control_fields() Deb822[source]

Reads the control information from a dsc

Returns:

fields is the dsc information in a dictionary form

scan_contents() set[str][source]

Returns a set of names for non directories. The path names are normalized after converting them from either utf-8 or iso8859-1 encoding.

class daklib.dbconn.DSCFile(*args, **kwargs)[source]
class daklib.dbconn.DebVersion[source]
bind_processor(dialect)[source]

Return a conversion function for processing bind values.

Returns a callable which will receive a bind parameter value as the sole positional argument and will return a value to send to the DB-API.

If processing is not necessary, the method should return None.

Note

This method is only called relative to a dialect specific type object, which is often private to a dialect in use and is not the same type object as the public facing one, which means it’s not feasible to subclass a types.TypeEngine class in order to provide an alternate _types.TypeEngine.bind_processor() method, unless subclassing the _types.UserDefinedType class explicitly.

To provide alternate behavior for _types.TypeEngine.bind_processor(), implement a _types.TypeDecorator class and provide an implementation of _types.TypeDecorator.process_bind_param().

Parameters:

dialect – Dialect instance in use.

get_col_spec()[source]
result_processor(dialect, coltype)[source]

Return a conversion function for processing result row values.

Returns a callable which will receive a result row column value as the sole positional argument and will return a value to return to the user.

If processing is not necessary, the method should return None.

Note

This method is only called relative to a dialect specific type object, which is often private to a dialect in use and is not the same type object as the public facing one, which means it’s not feasible to subclass a types.TypeEngine class in order to provide an alternate _types.TypeEngine.result_processor() method, unless subclassing the _types.UserDefinedType class explicitly.

To provide alternate behavior for _types.TypeEngine.result_processor(), implement a _types.TypeDecorator class and provide an implementation of _types.TypeDecorator.process_result_value().

Parameters:
  • dialect – Dialect instance in use.

  • coltype – DBAPI coltype argument received in cursor.description.

class daklib.dbconn.ExternalOverride(*args, **kwargs)[source]
class daklib.dbconn.Fingerprint(fingerprint=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

exception daklib.dbconn.IntegrityError(statement, params, orig, hide_parameters=False, connection_invalidated=False, code=None, ismulti=None)[source]

Wraps a DB-API IntegrityError.

code = 'gkpj'
class daklib.dbconn.Keyring(*args, **kwargs)[source]
de_escape_gpg_str(txt: str) str[source]
fpr_lookup: dict[str, str] = {}
generate_users_from_keyring(format: str, session) tuple[dict[str, tuple[int, str]], dict[int, tuple[str, str]]][source]
import_users_from_ldap(session) tuple[dict[str, tuple[int, str]], dict[int, tuple[str, str]]][source]
keys = {}
load_keys(keyring: str) None[source]
parse_address(uid: str) tuple[str, str][source]

parses uid and returns a tuple of real name and email address

class daklib.dbconn.Maintainer(name=None)[source]
get_split_maintainer() tuple[str, str, str, str][source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.MetadataKey(key=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.NewComment(*args, **kwargs)[source]
class daklib.dbconn.ORMObject[source]

ORMObject is a base class for all ORM classes mapped by SQLalchemy. All derived classes must implement the properties() method.

classname() str[source]

Returns the name of the class.

classmethod get(primary_key, session=None)[source]

This is a support function that allows getting an object by its primary key.

Architecture.get(3[, session])

instead of the more verbose

session.query(Architecture).get(3)

properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

session()[source]

Returns the current session that is associated with the object. May return None is object is in detached state.

class daklib.dbconn.Override(package=None, suite=None, component=None, overridetype=None, section=None, priority=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.OverrideType(overridetype=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.PolicyQueue(*args, **kwargs)[source]
class daklib.dbconn.PolicyQueueByhandFile[source]
class daklib.dbconn.PolicyQueueUpload[source]
_key()[source]
class daklib.dbconn.PoolFile(filename=None, filesize=-1, md5sum=None)[source]
property basename: str
property component: Component
property fullpath: str
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.Priority(priority=None, level=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

exception daklib.dbconn.SQLAlchemyError(*arg, **kw)[source]

Generic error class.

_message(as_unicode=True)[source]
_sql_message(as_unicode)[source]
class daklib.dbconn.Section(section=None)[source]
_sa_class_manager = {'created': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'modified': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'section': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'section_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
created
modified
section
section_id
class daklib.dbconn.SignatureHistory[source]
classmethod from_signed_file(signed_file: SignedFile) SignatureHistory[source]

signature history entry from signed file

Parameters:

signed_file – signed file

query(session)[source]
class daklib.dbconn.SourceMetadata(key=None, value=None, source=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.SrcContents(file=None, source=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.SrcFormat(*args, **kwargs)[source]
class daklib.dbconn.Suite(suite_name=None, version=None)[source]
details() str[source]
get_architectures(skipsrc: bool = False, skipall: bool = False) list[daklib.database.architecture.Architecture][source]

Returns list of Architecture objects

Parameters:
  • skipsrc – Whether to skip returning the ‘source’ architecture entry

  • skipall – Whether to skip returning the ‘all’ architecture entry

Returns:

list of Architecture objects for the given name (may be empty)

get_overridesuite() Suite[source]
get_sources(source: str) Query[source]

Returns a query object representing DBSource that is part of this suite.

Parameters:

source – source package name

Returns:

a query of DBSource

property path: str
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

property release_suite_output: str
update_last_changed() None[source]
class daklib.dbconn.Uid(uid=None, name=None)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

class daklib.dbconn.VersionCheck(*args, **kwargs)[source]
properties() list[str][source]

This method should be implemented by all derived classes and returns a list of the important properties. The properties ‘created’ and ‘modified’ will be added automatically. A suffix ‘_count’ should be added to properties that are lists or query objects. The most important property name should be returned as the first element in the list because it is used by repr().

daklib.dbconn.get_active_keyring_paths(session=None) list[str][source]
Returns:

list of active keyring paths

daklib.dbconn.get_architecture(architecture: str, session=None) Optional[Architecture][source]

Returns database id for given architecture.

Parameters:
  • architecture – The name of the architecture

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

Architecture object for the given arch (None if not present)

daklib.dbconn.get_archive(archive: str, session=None) Optional[Archive][source]

returns database id for given archive.

Parameters:
  • archive – the name of the arhive

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

Archive object for the given name (None if not present)

daklib.dbconn.get_component(component: str, session=None) Optional[Component][source]

Returns database id for given component.

Parameters:

component – The name of the override type

Returns:

the database id for the given component

daklib.dbconn.get_component_by_package_suite(package: str, suite_list: list[str], arch_list: Optional[str] = None, session=None) Optional[str][source]

Returns the component name of the newest binary package in suite_list or None if no package is found. The result can be optionally filtered by a list of architecture names.

Parameters:
  • package – DBBinary package name to search for

  • suite_list – list of suite_name items

  • arch_list – optional list of arch_string items that defaults to []

Returns:

name of component or None

daklib.dbconn.get_component_names(session=None) list[str][source]

Returns list of strings of component names.

Returns:

list of strings of component names

daklib.dbconn.get_dbchange(filename: str, session=None) Optional[DBChange][source]

returns DBChange object for given filename.

Parameters:
  • filename – the name of the file

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

DBChange object for the given filename (None if not present)

daklib.dbconn.get_dscfiles(dscfile_id: Optional[int] = None, source_id: Optional[int] = None, poolfile_id: Optional[int] = None, session=None) list[daklib.dbconn.DSCFile][source]

Returns a list of DSCFiles which may be empty

Parameters:
  • dscfile_id – the dscfile_id of the DSCFiles to find

  • source_id – the source id related to the DSCFiles to find

  • poolfile_id – the poolfile id related to the DSCFiles to find

Returns:

Possibly empty list of DSCFiles

daklib.dbconn.get_fingerprint(fpr: str, session=None) Optional[Fingerprint][source]

Returns Fingerprint object for given fpr.

Parameters:
  • fpr – The fpr to find / add

  • session – Optional SQL session object (a temporary one will be generated if not supplied).

Returns:

the Fingerprint object for the given fpr or None

daklib.dbconn.get_keyring(keyring: str, session=None) Optional[Keyring][source]

If keyring does not have an entry in the keyrings table yet, return None If keyring already has an entry, simply return the existing Keyring

Parameters:

keyring – the keyring name

Returns:

the Keyring object for this keyring

daklib.dbconn.get_maintainer(maintainer_id: int, session=None) Optional[Maintainer][source]

Return the name of the maintainer behind maintainer_id or None if that maintainer_id is invalid.

Parameters:

maintainer_id – the id of the maintainer

Returns:

the Maintainer with this maintainer_id

daklib.dbconn.get_mapped_component(component_name: str, session=None) Optional[Component][source]

get component after mappings

Evaluate component mappings from ComponentMappings in dak.conf for the given component name.

Parameters:
  • component_name – component name

  • session – database session

Returns:

component after applying maps or None

daklib.dbconn.get_mapped_component_name(component_name)[source]
daklib.dbconn.get_new_comments(policy_queue: PolicyQueue, package: Optional[str] = None, version: Optional[str] = None, comment_id: Optional[int] = None, session=None) list[daklib.dbconn.NewComment][source]

Returns (possibly empty) list of NewComment objects for the given parameters

Parameters:
  • package – name of the package

  • version – package version

  • comment_id – An id of a comment

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

A (possibly empty) list of NewComment objects will be returned

daklib.dbconn.get_or_set_fingerprint(fpr: str, session=None) Fingerprint[source]

Returns Fingerprint object for given fpr.

If no matching fpr is found, a row is inserted.

Parameters:
  • fpr – The fpr to find / add

  • session – Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting. A flush will be performed either way.

Returns:

the Fingerprint object for the given fpr

daklib.dbconn.get_or_set_maintainer(name: str, session=None) Maintainer[source]

Returns Maintainer object for given maintainer name.

If no matching maintainer name is found, a row is inserted.

Parameters:
  • name – The maintainer name to add

  • session – Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting. A flush will be performed either way.

Returns:

the Maintainer object for the given maintainer

daklib.dbconn.get_or_set_metadatakey(keyname: str, session=None) MetadataKey[source]

Returns MetadataKey object for given uidname.

If no matching keyname is found, a row is inserted.

Parameters:
  • keyname – The keyname to add

  • session – Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting.

Returns:

the metadatakey object for the given keyname

daklib.dbconn.get_or_set_uid(uidname: str, session=None) Uid[source]

Returns uid object for given uidname.

If no matching uidname is found, a row is inserted.

Parameters:
  • uidname – The uid to add

  • session – Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting.

Returns:

the uid object for the given uidname

daklib.dbconn.get_override(package: str, suite: Optional[Union[str, list[str]]] = None, component: Optional[Union[str, list[str]]] = None, overridetype: Optional[Union[str, list[str]]] = None, session=None) list[daklib.dbconn.Override][source]

Returns Override object for the given parameters

Parameters:
  • package – The name of the package

  • suite – The name of the suite (or suites if a list) to limit to. If None, don’t limit. Defaults to None.

  • component – The name of the component (or components if a list) to limit to. If None, don’t limit. Defaults to None.

  • overridetype – The name of the overridetype (or overridetypes if a list) to limit to. If None, don’t limit. Defaults to None.

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

A (possibly empty) list of Override objects will be returned

daklib.dbconn.get_override_type(override_type: str, session=None) Optional[OverrideType][source]

Returns OverrideType object for given override_type.

Parameters:
  • override_type – The name of the override type

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

the database id for the given override type

daklib.dbconn.get_policy_queue(queuename: str, session=None) Optional[PolicyQueue][source]

Returns PolicyQueue object for given queuename

Parameters:
  • queuename – The name of the queue

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

PolicyQueue object for the given queue

daklib.dbconn.get_priorities(session=None) dict[str, int][source]

Returns dictionary of priority names -> id mappings

Parameters:

session – Optional SQL session object (a temporary one will be generated if not supplied)

Returns:

dictionary of priority names -> id mappings

daklib.dbconn.get_priority(priority: str, session=None) Optional[Priority][source]

Returns Priority object for given priority name.

Parameters:
  • priority – The name of the priority

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

Priority object for the given priority

daklib.dbconn.get_section(section: str, session=None) Optional[Section][source]

Returns Section object for given section name.

Parameters:
  • section – The name of the section

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

Section object for the given section name

daklib.dbconn.get_sections(session=None) dict[str, int][source]

Returns dictionary of section names -> id mappings

Parameters:

session – Optional SQL session object (a temporary one will be generated if not supplied)

Returns:

dictionary of section names -> id mappings

daklib.dbconn.get_source_in_suite(source: str, suite_name: Optional[str], session=None) Optional[DBSource][source]

Returns a DBSource object for a combination of source and suite_name.

Parameters:
  • source – source package name

  • suite_name – the suite name

Returns:

the version for source in suite

daklib.dbconn.get_suite(suite: str, session=None) Optional[Suite][source]

Returns Suite object for given suite name.

Parameters:
  • suite – The name of the suite

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

Returns:

Suite object for the requested suite name (None if not present)

daklib.dbconn.get_suite_architectures(suite: str, skipsrc: bool = False, skipall: bool = False, session=None) list[daklib.database.architecture.Architecture][source]

Returns list of Architecture objects for given suite name. The list is empty if suite does not exist.

Parameters:
  • suite – Suite name to search for

  • skipsrc – Whether to skip returning the ‘source’ architecture entry

  • skipall – Whether to skip returning the ‘all’ architecture entry

  • session – Optional SQL session object (a temporary one will be generated if not supplied)

Returns:

list of Architecture objects for the given name (may be empty)

daklib.dbconn.get_suites_binary_in(package: str, session=None) list[daklib.dbconn.Suite][source]

Returns list of Suite objects which given package name is in

Parameters:

package – DBBinary package name to search for

Returns:

list of Suite objects for the given package

daklib.dbconn.get_suites_source_in(source: str, session=None) list[daklib.dbconn.Suite][source]

Returns list of Suite objects which given source name is in

Parameters:

source – DBSource package name to search for

Returns:

list of Suite objects for the given source

daklib.dbconn.get_uid_from_fingerprint(fpr: str, session=None) Optional[Uid][source]
daklib.dbconn.get_version_checks(suite_name: str, check: Optional[str] = None, session=None) list[daklib.dbconn.VersionCheck][source]
daklib.dbconn.has_new_comment(policy_queue: PolicyQueue, package: str, version: str, session=None) bool[source]

Returns True if the given combination of package, version has a comment.

Parameters:
  • package – name of the package

  • version – package version

  • session – Optional SQLA session object (a temporary one will be generated if not supplied)

daklib.dbconn.import_metadata_into_db(obj: Union[DBBinary, DBSource], session=None) None[source]

This routine works on either DBBinary or DBSource objects and imports their metadata into the database

daklib.dbconn.session_wrapper(fn)[source]

Wrapper around common “.., session=None):” handling. If the wrapped function is called without passing ‘session’, we create a local one and destroy it when the function ends.

Also attaches a commit_or_flush method to the session; if we created a local session, this is a synonym for session.commit(), otherwise it is a synonym for session.flush().