From d35486e0da1e115b475e7adee6f89d414761f131 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Wed, 4 Dec 2024 16:05:14 -0500 Subject: [PATCH] add new spec `package_version` to differentiate package version from flow list version; bump both --- fedelemflowlist/globals.py | 3 ++- fedelemflowlist/jsonld.py | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fedelemflowlist/globals.py b/fedelemflowlist/globals.py index 659f1f4..e7e2f9f 100644 --- a/fedelemflowlist/globals.py +++ b/fedelemflowlist/globals.py @@ -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"], diff --git a/fedelemflowlist/jsonld.py b/fedelemflowlist/jsonld.py index 5129c25..19d677e 100644 --- a/fedelemflowlist/jsonld.py +++ b/fedelemflowlist/jsonld.py @@ -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": @@ -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 @@ -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) @@ -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))