_emerge.PackageVirtualDbapi module

class _emerge.PackageVirtualDbapi.PackageVirtualDbapi(settings)

Bases: portage.dbapi.dbapi

A dbapi-like interface class that represents the state of the installed package database as new packages are installed, replacing any packages that previously existed in the same slot. The main difference between this class and fakedbapi is that this one uses Package instances internally (passed in via cpv_inject() and cpv_remove() calls).

_categories = None
_category_re = re.compile('^\\w[-.+\\w]*$')
static _cmp_cpv(cpv1, cpv2)
static _cpv_sort_ascending(cpv_list)

Use this to sort self.cp_list() results in ascending order. It sorts in place and returns None.

_iter_match(atom, cpv_iter)
_iter_match_repo(atom, cpv_iter)
_iter_match_slot(atom, cpv_iter)
_iter_match_use(atom, cpv_iter)
  1. Check for required IUSE intersection (need implicit IUSE here).

  2. Check enabled/disabled flag states.

_iuse_implicit_cnstr(pkg, metadata)

Construct a callable that checks if a given USE flag should be considered to be a member of the implicit IUSE for the given package.


a callable that accepts a single USE flag argument, and returns True only if the USE flag should be considered to be a member of the implicit IUSE for the given package.

Return type


_match_use(atom, pkg, metadata, ignore_profile=False)
_pkg_str(cpv, repo)

This is used to contruct _pkg_str instances on-demand during matching. If cpv is a _pkg_str instance with slot attribute, then simply return it. Otherwise, fetch metadata and construct a _pkg_str instance. This may raise KeyError or InvalidData.

_pkg_str_aux_keys = ('EAPI', 'KEYWORDS', 'SLOT', 'repository')
_repoman_iuse_implicit_cnstr(pkg, metadata)

In repoman’s version of _iuse_implicit_cnstr, account for modifications of the self.settings reference between calls.

_use_mutable = False
aux_get(cpv, wants, myrepo=None)

Return the metadata keys in mylist for mycpv Args:

mycpv - “sys-apps/foo-1.0” mylist - [“SLOT”,”DEPEND”,”HOMEPAGE”] myrepo - The repository name.


a list of results, in order of keys in mylist, such as: [“0”,”>=sys-libs/bar-1.0”,”http://www.foo.com”] or [] if mycpv not found’

aux_update(cpv, values)
cpv - “sys-apps/foo-1.0”

metadata_updates = { key : newvalue }



property categories

Use self.cp_all() to generate a category list. Mutable instances can delete the self._categories attribute in cases when the cached categories become invalid and need to be regenerated.


Remove all packages.


Implement this in a child class Args

sort - return sorted results


A list of strings 1 per CP in the datastore

cp_list(mycp, use_cache=1)

Return all CPVs in the db Args:



A list of Strings, 1 per CPV

This function relies on a subclass implementing cp_all, this is why the hasattr is there

cpv_exists(cpv, myrepo=None)
get(item, default=None)
match(origdep, use_cache=1)

Given a dependency, try to find packages that match Args:

origdep - Depend atom use_cache - Boolean indicating if we should use the cache or not NOTE: Do we ever not want the cache?


a list of packages that match origdep

move_slot_ent(mylist, repo_match=None)

This function takes a sequence: Args:

mylist: a sequence of (atom, originalslot, newslot) repo_match: callable that takes single repo_name argument

and returns True if the update should be applied


The number of slotmoves this function did

update_ents(updates, onProgress=None, onUpdate=None)

Update metadata of all packages for package moves. :param updates: A list of move commands, or dict of {repo_name: list} :type updates: list or dict :param onProgress: A progress callback function :type onProgress: a callable that takes 2 integer arguments: maxval and curval :param onUpdate: A progress callback function called only

for packages that are modified by updates.