bw2data.backends.single_file#
Submodules#
Classes#
A MutableMapping is a generic container for associating |
|
Simple proxy for an exchange between activity datasets. Makes manipulation and use in command line more convenient. |
|
A data store for LCI databases where each database is stored as a |
Package Contents#
- class bw2data.backends.single_file.Activity(key, data={})[source]#
Bases:
bw2data.proxies.ActivityProxyBase
A MutableMapping is a generic container for associating key/value pairs.
This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__.
- _data#
- class bw2data.backends.single_file.Exchange(data, *args, **kwargs)[source]#
Bases:
bw2data.proxies.ExchangeProxyBase
Simple proxy for an exchange between activity datasets. Makes manipulation and use in command line more convenient.
Warning
This proxy is read only! To save changes to a dataset, you will need to work with the raw database data.
Usually these proxies are created by the activity, but you can instantiate one with the dictionary of exchange data and an Activity proxy of the consuming activity:
exchange = Exchange({"my exchange data": "goes here"})
Properties:
input: Returns activityoutput: Returns activityamountuncertainty: Returns dictionary of uncertainty datauncertainty_type: Returnsstats_arraysuncertainty typeunit
- class bw2data.backends.single_file.SingleFileDatabase(name)[source]#
Bases:
bw2data.backends.base.LCIBackend
A data store for LCI databases where each database is stored as a
picklefile.Databases are automatically versioned. See below for reversion, etc. methods
- Parameters:
*name* (str) – Name of the database to manage.
- filename_for_version(version=None)[source]#
Filename for given version; Default is current version.
- Returns:
Filename (not path)
- load(version=None, **kwargs)[source]#
Load the intermediate data for this database.
Can also load previous versions of this database’s intermediate data.
- Parameters:
version (*) – Version of the database to load. Default
versionis the latest version.- Returns:
The intermediate data, a dictionary.
- make_latest_version()[source]#
Make the current version the latest version.
Requires loading data because a new intermediate data file is created.
- register(**kwargs)[source]#
Register a database with the metadata store.
Databases must be registered before data can be written.
- revert(version)[source]#
Return data to a previous state.
Warning
Reverting can lead to data loss, e.g. if you revert from version 3 to version 1, and then save your database, you will overwrite version 2. Use
make_latest_version()before saving, which will set the current version to 4.- Parameters:
version (*) – Number of the version to revert to.
- versions()[source]#
Get a list of available versions of this database.
- Returns:
List of (version, datetime created) tuples.
- backend = 'singlefile'#
- property filename#
- Remove filesystem-unsafe characters and perform unicode normalization on ``self.name`` using :func:`.utils.safe_filename`.
- validator#
- property version#
- The current version number (integer) of this database.
- Returns:
Version number