Skip to content

Commit

Permalink
add new spec package_version to differentiate package version from …
Browse files Browse the repository at this point in the history
…flow list version; bump both
  • Loading branch information
bl-young committed Dec 4, 2024
1 parent 234b43f commit d35486e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion fedelemflowlist/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
stream=sys.stdout)

flow_list_specs = {
"list_version": "1.2.4",
"package_version": "1.2.5",
"list_version": "1.3.0",
"flow_classes": ["Biological", "Chemicals", "Energy", "Geological",
"Groups", "Land", "Other", "Water"],
"primary_context_classes": ["Directionality", "Environmental Media"],
Expand Down
17 changes: 10 additions & 7 deletions fedelemflowlist/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ def write_to(self, path: Path, zw: zipio.ZipWriter = None):
def _write_flows(self, zw: zipio.ZipWriter):
altflowlist=fedelemflowlist.get_alt_conversion()
for _, row in self.flow_list.iterrows():
description = "From FedElemFlowList_"+flow_list_specs['list_version']+'.'
description = (
f"From Federal Elementary Flow List "
f"v{flow_list_specs['list_version']}, written by "
f"fedelemflowlist v{flow_list_specs['package_version']}."
)
flow_class = row.get("Class")
if flow_class is not None:
description += " Flow Class: %s." % flow_class
description += f" Flow Class: {flow_class}."

preferred = row.get("Preferred", 0)
if preferred == 1 or preferred == "1":
Expand All @@ -182,8 +186,7 @@ def _write_flows(self, zw: zipio.ZipWriter):
fp.conversion_factor = 1.0
fp.flow_property = units.property_ref(row["Unit"])
if fp.flow_property is None:
log.warning("unknown unit %s in flow %s",
row["Unit"], row["Flow UUID"])
log.warning(f"unknown unit {row['Unit']} in flow {row['Flow UUID']}")
flow.flow_properties = [fp]
#Add in alternate unit flow propert(ies), if an alternate unit exists
#in the flows list, uses short list of altflowlist to assign one or more
Expand All @@ -197,8 +200,8 @@ def _write_flows(self, zw: zipio.ZipWriter):
altfp.conversion_factor = alternate['AltUnitConversionFactor']
altfp.flow_property = units.property_ref(alternate["AltUnit"])
if altfp.flow_property is None:
log.warning("unknown altunit %s in flow %s",
alternate["AltUnit"], row["Flow UUID"])
log.warning(f"unknown altunit {alternate['AltUnit']} "
f"in flow {row['Flow UUID']}")
else:
flow.flow_properties.append(altfp)
zw.write(flow)
Expand Down Expand Up @@ -231,5 +234,5 @@ def _write_mappings(self, zw: zipio.ZipWriter):
# as there are currenty only methods for writing RootEntity
# objects in the ZipWriter
zw._ZipWriter__zip.writestr(
"flow_mappings/" + flow_map["@id"] + ".json",
f"flow_mappings/{flow_map['@id']}.json",
json.dumps(flow_map))

0 comments on commit d35486e

Please sign in to comment.