portage.dbapi.virtual module¶
- class portage.dbapi.virtual.fakedbapi(settings=None, exclusive_slots=True, multi_instance=False)¶
Bases:
portage.dbapi.dbapi
A fake dbapi that allows consumers to inject/remove packages to/from it portage.settings is required to maintain the dbAPI.
- _categories = None¶
- _category_re = re.compile('^\\w[-.+\\w]*$')¶
- _clear_cache()¶
- 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.
- _instance_key_cpv(cpv, support_string=False)¶
- _instance_key_multi_instance(cpv, support_string=False)¶
- _iter_match(atom, cpv_iter)¶
- _iter_match_repo(atom, cpv_iter)¶
- _iter_match_slot(atom, cpv_iter)¶
- _iter_match_use(atom, cpv_iter)¶
Check for required IUSE intersection (need implicit IUSE here).
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.
- _known_keys = frozenset({'BDEPEND', 'DEFINED_PHASES', 'DEPEND', 'DESCRIPTION', 'EAPI', 'HOMEPAGE', 'IDEPEND', 'INHERIT', 'INHERITED', 'IUSE', 'KEYWORDS', 'LICENSE', 'PDEPEND', 'PROPERTIES', 'RDEPEND', 'REQUIRED_USE', 'RESTRICT', 'SLOT', 'SRC_URI'})¶
- _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')¶
- _set_multi_instance(multi_instance)¶
Enable or disable multi_instance mode. This should before any packages are injected, so that all packages are indexed with the same implementation of self._instance_key.
- _use_mutable = False¶
- aux_get(mycpv, 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.
- Returns:
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)¶
- Args:
- cpv - “sys-apps/foo-1.0”
metadata_updates = { key : newvalue }
- Returns:
None
- 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.
- clear()¶
Remove all packages.
- close_caches()¶
- cp_all(sort=False)¶
Implement this in a child class Args
sort - return sorted results
- Returns:
A list of strings 1 per CP in the datastore
- cp_list(mycp, use_cache=1, myrepo=None)¶
- cpv_all()¶
Return all CPVs in the db Args:
None
- Returns:
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(mycpv, myrepo=None)¶
- cpv_inject(mycpv, metadata=None)¶
Adds a cpv to the list of available packages. See the exclusive_slots constructor parameter for behavior with respect to SLOT metadata. :param mycpv: cpv for the package to inject :type mycpv: str :param metadata: dictionary of raw metadata for aux_get() calls :param metadata: dict
- cpv_remove(mycpv)¶
Removes a cpv from the list of available packages.
- invalidentry(mypath)¶
- 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?
- Returns:
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
- Returns:
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.
- class portage.dbapi.virtual.testdbapi¶
Bases:
object
A dbapi instance with completely fake functions to get by hitting disk TODO(antarus): This class really needs to be rewritten to have better stubs; but these work for now. The dbapi classes themselves need unit tests…and that will be a lot of work.