Package portage :: Package util :: Class LazyItemsDict
[hide private]

Class LazyItemsDict

source code

               object --+            
                        |            
   cache.mappings.Mapping --+        
                            |        
cache.mappings.MutableMapping --+    
                                |    
          cache.mappings.UserDict --+
                                    |
                                   LazyItemsDict

A mapping object that behaves like a standard dict except that it allows for lazy initialization of values via callable objects. Lazy items can be overwritten and deleted just as normal items.

Nested Classes [hide private]
  _LazyItem
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
addLazyItem(self, item_key, value_callable, *pargs, **kwargs)
Add a lazy item for the given key.
source code
 
addLazySingleton(self, item_key, value_callable, *pargs, **kwargs)
This is like addLazyItem except value_callable will only be called a maximum of 1 time and the result will be cached for future requests.
source code
 
update(self, *args, **kwargs) source code
 
__getitem__(self, item_key) source code
 
__setitem__(self, item_key, value) source code
 
__delitem__(self, item_key) source code
 
clear(self) source code
 
copy(self) source code
 
__copy__(self) source code
 
__deepcopy__(self, memo=None)
This forces evaluation of each contained lazy item, and deepcopy of the result.
source code

Inherited from cache.mappings.UserDict: __contains__, __iter__, __len__, __repr__, keys

Inherited from cache.mappings.MutableMapping: pop, popitem, setdefault

Inherited from cache.mappings.Mapping: get, items, iteritems, iterkeys, itervalues, values

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  lazy_items

Inherited from cache.mappings.UserDict: data

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

addLazyItem(self, item_key, value_callable, *pargs, **kwargs)

source code 

Add a lazy item for the given key. When the item is requested, value_callable will be called with *pargs and **kwargs arguments.

update(self, *args, **kwargs)

source code 
Overrides: cache.mappings.MutableMapping.update

__getitem__(self, item_key)
(Indexing operator)

source code 
Overrides: cache.mappings.UserDict.__getitem__

__setitem__(self, item_key, value)
(Index assignment operator)

source code 
Overrides: cache.mappings.UserDict.__setitem__

__delitem__(self, item_key)
(Index deletion operator)

source code 
Overrides: cache.mappings.UserDict.__delitem__

clear(self)

source code 
Overrides: cache.mappings.MutableMapping.clear

__deepcopy__(self, memo=None)

source code 

This forces evaluation of each contained lazy item, and deepcopy of the result. A TypeError is raised if any contained lazy item is not a singleton, since it is not necessarily possible for the behavior of this type of item to be safely preserved.