bw2data.backends.peewee.proxies#

Module Contents#

Classes#

Activity

A MutableMapping is a generic container for associating

Exchange

A MutableMapping is a generic container for associating

Exchanges

Iterator for exchanges with some additional methods.

class bw2data.backends.peewee.proxies.Activity(document=None, **kwargs)[source]#

Bases: bw2data.proxies.ActivityProxyBase

Inheritance diagram of bw2data.backends.peewee.proxies.Activity

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__.

Create an Activity proxy object.

If this is a new activity, can pass kwargs.

If the activity exists in the database, document should be an ActivityDataset.

property key[source]#
_change_code(new_code)[source]#
_change_database(new_database)[source]#
biosphere()[source]#
copy(code=None, **kwargs)[source]#

Copy the activity. Returns a new Activity.

code is the new activity code; if not given, a UUID is used.

kwargs are additional new fields and field values, e.g. name=’foo’

delete()[source]#
exchanges()[source]#
new_exchange(**kwargs)[source]#

Create a new exchange linked to this activity

production()[source]#
rp_exchange()[source]#

Return an Exchange object corresponding to the reference production. Uses the following in order:

  • The production exchange, if only one is present

  • The production exchange with the same name as the activity reference product.

Raises ValueError if no suitable exchange is found.

save()[source]#
substitution()[source]#
technosphere(include_substitution=True)[source]#
upstream(kinds=('technosphere',))[source]#
class bw2data.backends.peewee.proxies.Exchange(document=None, **kwargs)[source]#

Bases: bw2data.proxies.ExchangeProxyBase

Inheritance diagram of bw2data.backends.peewee.proxies.Exchange

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__.

Create an Exchange proxy object.

If this is a new exchange, can pass kwargs.

If the exchange exists in the database, document should be an ExchangeDataset.

delete()[source]#
save()[source]#
class bw2data.backends.peewee.proxies.Exchanges(key, kinds=None, reverse=False)[source]#

Bases: collections.abc.Iterable

Inheritance diagram of bw2data.backends.peewee.proxies.Exchanges

Iterator for exchanges with some additional methods.

This is not a generator; next() is not supported. Everything time you start to iterate over the object you get a new list starting from the beginning. However, to get a single item you can do next(iter(foo)).

Ordering is by database row id.

Supports the following:

exchanges = activity.exchanges()

# Iterate
for exc in exchanges:
    pass

# Length
len(exchanges)

# Delete all
exchanges.delete()
_get_queryset()[source]#
delete()[source]#
filter(expr)[source]#