yum.misc

Assorted utility functions for yum.

yum.misc.share_data(value)

Take a value and use the same value from the store, if the value isn’t in the store this one becomes the shared version.

yum.misc.unshare_data()
yum.misc.re_glob(s)

Tests if a string is a shell wildcard.

yum.misc.re_filename(s)

Tests if a string could be a filename. We still get negated character classes wrong (are they supported), and ranges in character classes.

yum.misc.re_primary_filename(filename)

Tests if a filename string, can be matched against just primary. Note that this can produce false negatives (but not false positives). Note that this is a superset of re_primary_dirname().

yum.misc.re_primary_dirname(dirname)

Tests if a dirname string, can be matched against just primary. Note that this is a subset of re_primary_filename().

yum.misc.re_full_search_needed(s)

Tests if a string needs a full nevra match, instead of just name.

yum.misc.re_remote_url(s)

Tests if a string is a “remote” URL, http, https, ftp.

yum.misc.unique(s)

Return a list of the elements in s, but without duplicates.

For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique(“abcabc”) some permutation of [“a”, “b”, “c”], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]].

For best speed, all sequence elements should be hashable. Then unique() will usually work in linear time.

If not possible, the sequence elements should enjoy a total ordering, and if list(s).sort() doesn’t raise TypeError it’s assumed that they do enjoy a total ordering. Then unique() will usually work in O(N*log2(N)) time.

If that’s not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.

Checksums

class yum.misc.Checksums(checksums=None, ignore_missing=False, ignore_none=False)

Generate checksum(s), on given pieces of data. Producing the Length and the result(s) when complete.

AutoFileChecksums

class yum.misc.AutoFileChecksums(fo, checksums, ignore_missing=False, ignore_none=False)

Generate checksum(s), on given file/fileobject. Pretending to be a file object (overrrides read).

yum.misc.checksum(sumtype, file, CHUNK=65536, datasize=None)

takes filename, hand back Checksum of it sumtype = md5 or sha/sha1/sha256/sha512 (note sha == sha1) filename = /path/to/file CHUNK=65536 by default

yum.misc.getFileList(path, ext, filelist)

Return all files in path matching ext, store them in filelist, recurse dirs return list object

GenericHolder

class yum.misc.GenericHolder(iter=None)

Generic Holder class used to hold other objects of known types It exists purely to be able to do object.somestuff, object.someotherstuff or object[key] and pass object to another function that will understand it

yum.misc.procgpgkey(rawkey)

Convert ASCII armoured GPG key to binary

yum.misc.getgpgkeyinfo(rawkey, multiple=False)

Return a dict of info for the given ASCII armoured key text

Returned dict will have the following keys: ‘userid’, ‘keyid’, ‘timestamp’

Will raise ValueError if there was a problem decoding the key.

yum.misc.keyIdToRPMVer(keyid)

Convert an integer representing a GPG key ID to the hex version string used by RPM

yum.misc.keyInstalled(ts, keyid, timestamp)

Return if the GPG key described by the given keyid and timestamp are installed in the rpmdb.

The keyid and timestamp should both be passed as integers. The ts is an rpm transaction set object

Return values:
  • -1

    key is not installed

  • 0 key with matching ID and timestamp is installed

  • 1 key with matching ID is installed but has a older timestamp

  • 2 key with matching ID is installed but has a newer timestamp

No effort is made to handle duplicates. The first matching keyid is used to calculate the return result.

yum.misc.import_key_to_pubring(rawkey, keyid, cachedir=None, gpgdir=None, make_ro_copy=True)
yum.misc.return_keyids_from_pubring(gpgdir)
yum.misc.valid_detached_sig(sig_file, signed_file, gpghome=None)

takes signature , file that was signed and an optional gpghomedir

yum.misc.getCacheDir(tmpdir='/var/tmp', reuse=True, prefix='yum-')

return a path to a valid and safe cachedir - only used when not running as root or when –tempcache is set

yum.misc.sortPkgObj(pkg1, pkg2)

sorts a list of yum package objects by name

yum.misc.newestInList(pkgs)

Return the newest in the list of packages.

yum.misc.version_tuple_to_string(evrTuple)

Convert a tuple representing a package version to a string.

@param evrTuple: A 3-tuple of epoch, version, and release.

Return the string representation of evrTuple.

yum.misc.prco_tuple_to_string(prcoTuple)

returns a text string of the prco from the tuple format

yum.misc.string_to_prco_tuple(prcoString)

returns a prco tuple (name, flags, (e, v, r)) for a string

yum.misc.refineSearchPattern(arg)

Takes a search string from the cli for Search or Provides and cleans it up so it doesn’t make us vomit

yum.misc.bunzipFile(source, dest)

Extract the bzipped contents of source to dest.

yum.misc.get_running_kernel_pkgtup(ts)

This takes the output of uname and figures out the pkgtup of the running kernel (name, arch, epoch, version, release).

yum.misc.get_running_kernel_version_release(ts)

This takes the output of uname and figures out the (version, release) tuple for the running kernel.

yum.misc.find_unfinished_transactions(yumlibpath='/var/lib/yum')

returns a list of the timestamps from the filenames of the unfinished transactions remaining in the yumlibpath specified.

yum.misc.find_ts_remaining(timestamp, yumlibpath='/var/lib/yum')

this function takes the timestamp of the transaction to look at and the path to the yum lib dir (defaults to /var/lib/yum) returns a list of tuples(action, pkgspec) for the unfinished transaction elements. Returns an empty list if none.

yum.misc.seq_max_split(seq, max_entries)

Given a seq, split into a list of lists of length max_entries each.

yum.misc.to_xml(item, attrib=False)

Call os.unlink, but don’t die if the file isn’t there. This is the main difference between “rm -f” and plain “rm”.

yum.misc.stat_f(filename, ignore_EACCES=False)

Call os.stat(), but don’t die if the file isn’t there. Returns None.

yum.misc.getloginuid()

Get the audit-uid/login-uid, if available. None is returned if there was a problem. The value is cached, so you don’t have to save it.

yum.misc.setup_locale(override_codecs=True, override_time=False)
yum.misc.get_my_lang_code()
yum.misc.return_running_pids()

return list of running processids, excluding this one

yum.misc.get_open_files(pid)

returns files open from this pid

yum.misc.get_uuid(savepath)

create, store and return a uuid. If a stored one exists, report that if it cannot be stored, return a random one

yum.misc.decompress(filename, dest=None, fn_only=False, check_timestamps=False)

take a filename and decompress it into the same relative location. if the file is not compressed just return the file

yum.misc.repo_gen_decompress(filename, generated_name, cached=False)

This is a wrapper around decompress, where we work out a cached generated name, and use check_timestamps. filename _must_ be from a repo. and generated_name is the type of the file.

yum.misc.read_in_items_from_dot_dir(thisglob, line_as_list=True)

takes a glob of a dir (like /etc/foo.d/*.foo) returns a list of all the lines in all the files matching that glob, ignores comments and blank lines, optional paramater ‘line_as_list tells whether to treat each line as a space or comma-separated list, defaults to True

yum.misc.cElementTree_iterparse(filename)

Lazily load/run: cElementTree.iterparse

yum.misc.cElementTree_xmlparse(filename)

Lazily load/run: cElementTree.parse

Table Of Contents

Previous topic

yum.metalink

Next topic

yum.packageSack

This Page