osc.util package
Submodules
osc.util.ar module
- exception osc.util.ar.ArError(fn, msg)
Bases:
Exception
Base class for all ar related errors
- class osc.util.ar.ArHdr(fn, date, uid, gid, mode, size, fmag, off)
Bases:
object
Represents an ar header entry
osc.util.archquery module
- exception osc.util.archquery.ArchError(fname, msg)
Bases:
PackageError
- class osc.util.archquery.ArchQuery(fh)
Bases:
PackageQuery
,PackageQueryResult
- read(all_tags=True, self_provides=True, *extra_tags)
Returns a PackageQueryResult instance
- vercmp(archq)
- name()
- version()
- release()
- epoch()
- arch()
- description()
- path()
- provides()
- requires()
- conflicts()
- obsoletes()
- recommends()
- suggests()
- supplements()
- enhances()
- canonname()
- gettag(tag)
- static query(filename, all_tags=False, *extra_tags)
- static rpmvercmp(ver1, ver2)
implementation of RPM’s version comparison algorithm (as described in lib/rpmvercmp.c)
- static filename(name, epoch, version, release, arch)
osc.util.cpio module
- exception osc.util.cpio.CpioError(fn, msg)
Bases:
Exception
base class for all cpio related errors
- class osc.util.cpio.CpioHdr(mgc, ino, mode, uid, gid, nlink, mtime, filesize, dev_maj, dev_min, rdev_maj, rdev_min, namesize, checksum, off=-1, filename=b'')
Bases:
object
Represents a cpio header (“New” portable format and CRC format).
- class osc.util.cpio.CpioRead(filename)
Bases:
object
Represents a cpio archive. Supported formats: * ascii SVR4 no CRC also called “new_ascii”
- sfmt = {'newascii': b'070701'}
- hdr_fmt = '6s8s8s8s8s8s8s8s8s8s8s8s8s8s'
- hdr_len = 110
- read()
- copyin_file(filename, dest=None, new_fn=None)
copies filename to dest. If dest is None the file will be stored in $PWD/filename. If dest points to a dir the file will be stored in dest/filename. In case new_fn is specified the file will be stored as new_fn.
- copyin(dest=None)
extracts the cpio archive to dest. If dest is None $PWD will be used.
osc.util.debquery module
- exception osc.util.debquery.DebError(fname, msg)
Bases:
PackageError
- class osc.util.debquery.DebQuery(fh)
Bases:
PackageQuery
,PackageQueryResult
- default_tags = (b'package', b'version', b'release', b'epoch', b'architecture', b'description', b'provides', b'depends', b'pre_depends', b'conflicts', b'breaks')
- read(all_tags=False, self_provides=True, *extra_tags)
Returns a PackageQueryResult instance
- vercmp(debq)
- name()
- version()
- release()
- epoch()
- arch()
- description()
- path()
- provides()
- requires()
- conflicts()
- obsoletes()
- recommends()
- suggests()
- supplements()
- enhances()
- gettag(num)
- canonname()
- static query(filename, all_tags=False, *extra_tags)
- static debvercmp(ver1, ver2)
implementation of dpkg’s version comparison algorithm
- static filename(name, epoch, version, release, arch)
osc.util.packagequery module
- exception osc.util.packagequery.PackageError(fname, msg)
Bases:
Exception
base class for all package related errors
- class osc.util.packagequery.PackageQueries(wanted_architecture)
Bases:
dict
Dict of package name keys and package query values. When assigning a package query, to a name, the package is evaluated to see if it matches the wanted architecture and if it has a greater version than the current value.
- architectureMap = {'amd64': ['x86_64'], 'armv6hl': ['armv6l'], 'armv7hl': ['armv7l'], 'i386': ['i586', 'i686'], 'ppc64el': ['ppc64le']}
- add(query)
Adds package query to dict if it is of the correct architecture and is newer (has a greater version) than the currently assigned package.
- Parameters:
query – a PackageQuery
- class osc.util.packagequery.PackageQuery
Bases:
object
abstract base class for all package types
- read(all_tags=False, *extra_tags)
Returns a PackageQueryResult instance
- static query(filename, all_tags=False, extra_rpmtags=(), extra_debtags=(), self_provides=True)
- static queryhdrmd5(filename)
- class osc.util.packagequery.PackageQueryResult
Bases:
object
abstract base class that represents the result of a package query
- name()
- version()
- release()
- epoch()
- arch()
- description()
- path()
- provides()
- requires()
- conflicts()
- obsoletes()
- recommends()
- suggests()
- supplements()
- enhances()
- gettag(tag)
- vercmp(pkgquery)
- canonname()
- evr()
- osc.util.packagequery.cmp(a, b)
osc.util.repodata module
Module for reading repodata directory (created with createrepo) for package information instead of scanning individual rpms.
- osc.util.repodata.namespace(name)
- osc.util.repodata.primaryPath(directory)
Returns path to the primary repository data file.
- Parameters:
directory – repository directory that contains the repodata subdirectory
- Returns:
path to primary repository data file
- Return type:
str
- Raises:
IOError – if repomd.xml contains no primary location
- osc.util.repodata.queries(directory)
Returns a list of RepoDataQueries constructed from the repodata under the directory.
- Parameters:
directory – path to a repository directory (parent directory of repodata directory)
- Returns:
list of RepoDataQueryResult instances
- Raises:
IOError – if repomd.xml contains no primary location
- class osc.util.repodata.RepoDataQueryResult(directory, element)
Bases:
PackageQueryResult
PackageQueryResult that reads in data from the repodata directory files.
- arch(*args, **kwargs)
- description(*args, **kwargs)
- distribution()
- epoch(*args, **kwargs)
- name(*args, **kwargs)
- path()
- provides(*args, **kwargs)
- release(*args, **kwargs)
- requires(*args, **kwargs)
- conflicts(*args, **kwargs)
- obsoletes(*args, **kwargs)
- recommends(*args, **kwargs)
- suggests(*args, **kwargs)
- supplements(*args, **kwargs)
- enhances(*args, **kwargs)
- canonname()
- gettag(tag)
- vercmp(other)
- version(*args, **kwargs)
osc.util.rpmquery module
- osc.util.rpmquery.cmp(a, b)
- exception osc.util.rpmquery.RpmError(fname, msg)
Bases:
PackageError
- class osc.util.rpmquery.RpmHeader(offset, length)
Bases:
object
corresponds more or less to the indexEntry_s struct
- append(entry)
- gettag(tag)
- class osc.util.rpmquery.RpmHeaderEntry(tag, type, offset, count)
Bases:
object
corresponds to the entryInfo_s struct (except the data attribute)
- ENTRY_SIZE = 16
- class osc.util.rpmquery.RpmQuery(fh)
Bases:
PackageQuery
,PackageQueryResult
- LEAD_SIZE = 96
- LEAD_MAGIC = 3987467995
- HEADER_MAGIC = 2393761793
- HEADERSIG_TYPE = 5
- LESS = 2
- GREATER = 4
- EQUAL = 8
- SENSE_STRONG = 134217728
- default_tags = (1000, 1001, 1002, 1003, 1004, 1022, 1005, 1020, 1047, 1112, 1113, 1049, 1048, 1050, 1054, 1053, 1055, 1090, 1114, 1115, 1156, 1158, 1157, 5046, 5047, 5048, 5049, 5051, 5050, 5052, 5053, 5054, 5055, 5056, 5057)
- read(all_tags=False, self_provides=True, *extra_tags, **extra_kw)
Returns a PackageQueryResult instance
- vercmp(rpmq)
- name()
- version()
- release()
- epoch()
- arch()
- summary()
- description()
- url()
- path()
- provides()
- requires()
- conflicts()
- obsoletes()
- recommends()
- suggests()
- supplements()
- enhances()
- is_src()
- is_nosrc()
- gettag(num)
- canonname()
- static query(filename)
- static queryhdrmd5(filename)
- static rpmvercmp(ver1, ver2)
implementation of RPM’s version comparison algorithm (as described in lib/rpmvercmp.c)
- static filename(name, epoch, version, release, arch)
- osc.util.rpmquery.unpack_string(data, encoding=None)
unpack a ‘0’ terminated string from data
osc.util.safewriter module
osc.util.helper module
- osc.util.helper.decode_list(ilist)
Decodes the elements of a list if needed
- osc.util.helper.decode_it(obj)
Decode the given object unless it is a str.
If the given object is a str or has no decode method, the object itself is returned. Otherwise, try to decode the object using utf-8. If this fails due to a UnicodeDecodeError, try to decode the object using latin-1.
- osc.util.helper.raw_input(*args)
- osc.util.helper.format_table(rows, headers)
Format list of tuples into equal width table with headers