Scheduler._pkg().
* Define digraph.__contains__ for containment tests via the "in" operator.
svn path=/main/trunk/; revision=11021
settings.setcpv(pkg)
pkg.metadata["USE"] = settings["PORTAGE_USE"]
- if self._digraph and \
- self._digraph.contains(pkg):
- for existing_instance in self._digraph.order:
- if existing_instance == pkg:
- pkg = existing_instance
- break
+ if self._digraph is not None:
+ # Reuse existing instance when available.
+ pkg = self._digraph.get(pkg, pkg)
return pkg
"""Checks if the digraph contains mynode"""
return node in self.nodes
+ def get(self, key, default=None):
+ return self.nodes.get(key, default)
+
def all_nodes(self):
"""Return a list of all nodes in the graph"""
return self.order[:]
allnodes = all_nodes
allzeros = leaf_nodes
hasnode = contains
+ __contains__ = contains
empty = is_empty
copy = clone