self.nodes[parent] = ({}, {}, parent)
self.order.append(parent)
- priorities = self.nodes[node][1].setdefault(parent, [])
- priorities.append(priority)
- priorities.sort()
-
- priorities = self.nodes[parent][0].setdefault(node, [])
+ priorities = self.nodes[node][1].get(parent)
+ if priorities is None:
+ priorities = []
+ self.nodes[node][1][parent] = priorities
+ self.nodes[parent][0][node] = priorities
priorities.append(priority)
priorities.sort()
def clone(self):
clone = digraph()
clone.nodes = {}
+ memo = {}
for children, parents, node in self.nodes.itervalues():
children_clone = {}
for child, priorities in children.iteritems():
- children_clone[child] = priorities[:]
+ priorities_clone = memo.get(id(priorities))
+ if priorities_clone is None:
+ priorities_clone = priorities[:]
+ memo[id(priorities)] = priorities_clone
+ children_clone[child] = priorities_clone
parents_clone = {}
for parent, priorities in parents.iteritems():
- parents_clone[parent] = priorities[:]
+ priorities_clone = memo.get(id(priorities))
+ if priorities_clone is None:
+ priorities_clone = priorities[:]
+ memo[id(priorities)] = priorities_clone
+ parents_clone[parent] = priorities_clone
clone.nodes[node] = (children_clone, parents_clone, node)
clone.order = self.order[:]
return clone
"have been defined in\n!!! %s/make.globals.\n") \
% (resumecommand_var,
portage.const.GLOBAL_CONFIG_PATH),
- noiselevel=-1)
+ level=logging.ERROR, noiselevel=-1)
return 0
if "${FILE}" not in resumecommand:
portage.util.writemsg_level(
Instances of these serve as proxies to global variables
that are initialized on demand.
"""
+
+ __slots__ = ('_name',)
+
def __init__(self, name):
proxy.objectproxy.ObjectProxy.__init__(self)
object.__setattr__(self, '_name', name)
are needed while the portdb is not.
"""
+ __slots__ = ()
+
def _get_target(self):
init_legacy_globals()
global db, portdb, root, _portdb_initialized
The mtimedb is independent from the portdb and other globals.
"""
+ __slots__ = ('_name',)
+
def __init__(self, name):
proxy.objectproxy.ObjectProxy.__init__(self)
object.__setattr__(self, '_name', name)
If update is specified, updateNewsItems( repoid ) will be called to
check for new items.
"""
-
+
if update:
self.updateItems(repoid)
-
+
unread_filename = self._unread_filename(repoid)
unread_lock = None
try:
Creation of a news item involves passing in the path to the particular news item.
"""
-
+
def __init__(self, path, name):
- """
+ """
For a given news item we only want if it path is a file.
"""
self.path = path
if not len(self.restrictions):
return True # no restrictions to match means everyone should see it
-
+
kwargs = \
{ 'vardb' : vardb,
'config' : config,
for restriction in self.restrictions:
if restriction.checkRestriction(**kwargs):
return True
-
+
return False # No restrictions were met; thus we aren't relevant :(
def isValid(self):
An Installation restriction where a particular item shall only be displayed
if the user has that item installed.
"""
-
+
def __init__(self, atom):
self.atom = atom
import stat
import string
import sys
-import types
from portage.exception import PortageException, FileNotFound, \
OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem
self.addLazyItem(item_key,
self._SingletonWrapper(self, item_key, value_callable,
*pargs, **kwargs))
- def update(self, map_obj):
- if isinstance(map_obj, LazyItemsDict):
+
+ def update(self, *args, **kwargs):
+ if len(args) > 1:
+ raise TypeError(
+ "expected at most 1 positional argument, got " + \
+ repr(len(args)))
+ if args:
+ map_obj = args[0]
+ else:
+ map_obj = None
+ if map_obj is None:
+ pass
+ elif isinstance(map_obj, LazyItemsDict):
for k in map_obj:
if k in map_obj.lazy_items:
dict.__setitem__(self, k, None)
self.lazy_items.update(map_obj.lazy_items)
else:
dict.update(self, map_obj)
+ if kwargs:
+ dict.update(self, kwargs)
+
def __getitem__(self, item_key):
if item_key in self.lazy_items:
value_callable, pargs, kwargs = self.lazy_items[item_key]