def add_input_info_for_external_exchanges(activities, names):
"""Add details on exchange inputs from other databases"""
names = set(names)
cache = {}
for ds in tqdm(activities):
for exc in ds['exchanges']:
if 'input' not in exc or exc['input'][0] in names:
continue
if exc['input'] not in cache:
cache[exc['input']] = ActivityDataset.get(
ActivityDataset.database == exc['input'][0],
ActivityDataset.code == exc['input'][1],
)
obj = cache[exc['input']]
exc['name'] = obj.name
exc['product'] = obj.product
exc['unit'] = obj.data['unit']
exc['location'] = obj.location
if exc['type'] == 'biosphere':
exc['categories'] = obj.data['categories']
评论列表
文章目录