Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Nov 20, 2023
2 parents ce733ed + 48a6ab0 commit 7fbf75f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fedelemflowlist/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
stream=sys.stdout)

flow_list_specs = {
"list_version": "1.2.1",
"list_version": "1.2.2",
"flow_classes": ["Biological", "Chemicals", "Energy", "Geological",
"Groups", "Land", "Other", "Water"],
"primary_context_classes": ["Directionality", "Environmental Media"],
Expand Down
23 changes: 14 additions & 9 deletions fedelemflowlist/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path
from typing import Optional
import pandas as pd
import json

try:
import olca_schema as o
Expand Down Expand Up @@ -61,23 +62,21 @@ def to_json(self) -> dict:
flow_ref = o.Ref()
flow_ref.name = self.name
if self.category is not None:
flow_ref.category_path = self.category.split('/')
flow_ref.category = self.category

# set the UUID or generate it from the attributes
if self.uid is None:
flow_ref.id = make_uuid("Flow",
self.category, self.name)
flow_ref.id = make_uuid("Flow", self.category, self.name)
else:
flow_ref.id = self.uid

json = {
'flow': flow_ref.to_json()
'flow': flow_ref.to_dict()
}
if self.unit is not None:
unit_ref = units.unit_ref(self.unit)
if unit_ref is not None:
json['unit'] = unit_ref.to_json()

json['unit'] = unit_ref.to_dict()
return json


Expand Down Expand Up @@ -210,15 +209,21 @@ def _write_mappings(self, zw: zipio.ZipWriter):

for source_list, entries in maps.items():
list_ref = o.Ref()
list_ref.o_type = 'FlowMap'
list_ref.ref_type = o.RefType.FlowMap
list_ref.name = source_list
mappings = []
flow_map = {
'@id': str(uuid.uuid4()),
'name': '%s -> Fed.LCA Commons' % source_list,
'source': list_ref.to_json(),
'source': list_ref.to_dict(),
'mappings': mappings
}
for e in entries:
mappings.append(e.to_json())
zw.write_json(flow_map, 'flow_mappings')

# an ugly hack to write the flow maps directly to the zip-file
# as there are currenty only methods for writing RootEntity
# objects in the ZipWriter
zw._ZipWriter__zip.writestr(
"flow_mappings/" + flow_map["@id"] + ".json",
json.dumps(flow_map))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='fedelemflowlist',
version='1.2.1',
version='1.2.2',
packages=['fedelemflowlist'],
package_dir={'fedelemflowlist': 'fedelemflowlist'},
package_data={'fedelemflowlist': [
Expand Down

0 comments on commit 7fbf75f

Please sign in to comment.