bw2calc.dictionary_manager#
Classes#
Class that handles dictionaries which can be remapped or reverse. |
|
A dictionary that can be easily remapped or reversed. |
Functions#
|
Decorator that resolves a |
Module Contents#
- class bw2calc.dictionary_manager.DictionaryManager[source]#
Class that handles dictionaries which can be remapped or reverse.
Usage:
dm = DictionaryManager() dm.foo = {1: 2} dm.foo[1] >> 2
- class bw2calc.dictionary_manager.ReversibleRemappableDictionary(obj)[source]#
Bases:
collections.abc.Mapping
A dictionary that can be easily remapped or reversed.
Perhaps overkill, but at the time it was easier than creating many dictionaries on the LCA object itself.
Example usage:
In [1]: from bw2calc.dictionary_manager import ReversibleRemappableDictionary In [2]: d = ReversibleRemappableDictionary({1: 2}) In [3]: d.reverse Out[3]: {2: 1} In [4]: d.remap({1: "foo"}) In [5]: d['foo'] Out[5]: 2 In [6]: d.original Out[6]: {1: 2} In [7]: d.reverse Out[7]: {2: 'foo'} In [8]: d.unmap() In [9]: d[1] Out[9]: 2