diff --git a/.github/workflows/github_action_trigger_submodule_pull_reusable.yml b/.github/workflows/trigger_submodule_update_reuse.yml similarity index 53% rename from .github/workflows/github_action_trigger_submodule_pull_reusable.yml rename to .github/workflows/trigger_submodule_update_reuse.yml index 8b103b59..82d19336 100644 --- a/.github/workflows/github_action_trigger_submodule_pull_reusable.yml +++ b/.github/workflows/trigger_submodule_update_reuse.yml @@ -1,5 +1,6 @@ -# this workflow re-uses the workflow 'github_action_trigger_submodule_pull_main.yml' in the brightway-documentation repository -name: Create Workflow Dispatch (Trigger Submodule Pull), Re-Use Workflow +# This workflow re-uses the workflow 'trigger_submodule_update_main.yml' +# from the brightway-documentation repository. +name: Re-Use Workflow - Create Workflow Dispatch (Trigger Submodule Update) on: push: @@ -10,5 +11,5 @@ on: jobs: re-use_workflow: uses: - brightway-lca/brightway-documentation/.github/workflows/github_action_trigger_submodule_pull_main.yml@main - secrets: inherit # https://docs.github.com/en/actions/using-workflows/reusing-workflows#passing-secrets-to-nested-workflows \ No newline at end of file + brightway-lca/brightway-documentation/.github/workflows/trigger_submodule_update_main.yml@main + secrets: inherit # https://docs.github.com/en/actions/using-workflows/reusing-workflows#passing-secrets-to-nested-workflows diff --git a/bw2io/extractors/csv.py b/bw2io/extractors/csv.py index 0e53fba4..c0b5ffea 100644 --- a/bw2io/extractors/csv.py +++ b/bw2io/extractors/csv.py @@ -17,7 +17,7 @@ class CSVExtractor(object): """ @classmethod - def extract(cls, filepath, encoding="utf-8-sig"): + def extract(cls, filepath, encoding="utf-8-sig", **kwargs): """ Extracts CSV file data from the filepath. @@ -47,4 +47,4 @@ def extract(cls, filepath, encoding="utf-8-sig"): with open(filepath, encoding=encoding) as f: reader = csv.reader(f) data = [row for row in reader] - return [os.path.basename(filepath), data] \ No newline at end of file + return [os.path.basename(filepath), data] diff --git a/bw2io/extractors/ecospold1_lcia.py b/bw2io/extractors/ecospold1_lcia.py index cd1cdcbb..9a5879bd 100644 --- a/bw2io/extractors/ecospold1_lcia.py +++ b/bw2io/extractors/ecospold1_lcia.py @@ -18,7 +18,7 @@ class Ecospold1LCIAExtractor(object): """ @classmethod - def extract(cls, path): + def extract(cls, path, **kwargs): """ Extracts ecospold XML file data. diff --git a/bw2io/extractors/ecospold2.py b/bw2io/extractors/ecospold2.py index 9ae683b2..95f3777a 100644 --- a/bw2io/extractors/ecospold2.py +++ b/bw2io/extractors/ecospold2.py @@ -235,13 +235,13 @@ def extract_activity(cls, dirpath, filename, db_name): "Included activities start: ", getattr2( stem.activityDescription.activity, "includedActivitiesStart" - ).get("text"), + ) ), ( "Included activities end: ", getattr2( stem.activityDescription.activity, "includedActivitiesEnd" - ).get("text"), + ) ), ( "Geography: ", @@ -264,7 +264,7 @@ def extract_activity(cls, dirpath, filename, db_name): ] comment = "\n".join( [ - (" ".join(x) if isinstance(x, tuple) else x) + (" ".join(str(i) for i in x) if isinstance(x, tuple) else x) for x in comments if (x[1] if isinstance(x, tuple) else x) ] diff --git a/bw2io/extractors/excel.py b/bw2io/extractors/excel.py index 3c2d1b03..9ef7949b 100644 --- a/bw2io/extractors/excel.py +++ b/bw2io/extractors/excel.py @@ -79,7 +79,7 @@ class ExcelExtractor: >>> data = extractor.extract(filepath) """ @classmethod - def extract(cls, filepath: Path): + def extract(cls, filepath: Path, **kwargs): """ Extract data from an Excel file. diff --git a/bw2io/extractors/json_ld.py b/bw2io/extractors/json_ld.py index 955880d6..19c79e6a 100644 --- a/bw2io/extractors/json_ld.py +++ b/bw2io/extractors/json_ld.py @@ -22,7 +22,7 @@ class JSONLDExtractor(object): Directories to ignore when extracting JSON-LD data. """ @classmethod - def extract(cls, filepath, add_filename=True): + def extract(cls, filepath, add_filename=True, **kwargs): """ Extracts JSON-LD data from the filepath. diff --git a/bw2io/extractors/simapro_csv.py b/bw2io/extractors/simapro_csv.py index befcc7af..6a829388 100644 --- a/bw2io/extractors/simapro_csv.py +++ b/bw2io/extractors/simapro_csv.py @@ -162,7 +162,7 @@ class SimaProCSVExtractor(object): """ @classmethod - def extract(cls, filepath, delimiter=";", name=None, encoding="cp1252"): + def extract(cls, filepath, delimiter=";", name=None, encoding="cp1252", **kwargs): """ Extract data from a SimaPro export file (.csv) and returns a list of datasets, global parameters, and project metadata. diff --git a/bw2io/extractors/simapro_lcia_csv.py b/bw2io/extractors/simapro_lcia_csv.py index 57d42147..0e348115 100644 --- a/bw2io/extractors/simapro_lcia_csv.py +++ b/bw2io/extractors/simapro_lcia_csv.py @@ -54,7 +54,7 @@ class SimaProLCIACSVExtractor(object): """ @classmethod - def extract(cls, filepath, delimiter=";", encoding="cp1252"): + def extract(cls, filepath, delimiter=";", encoding="cp1252", **kwargs): assert os.path.exists(filepath), "Can't find file %s" % filepath log, logfile = get_io_logger("SimaPro-LCIA-extractor") diff --git a/bw2io/strategies/lcia.py b/bw2io/strategies/lcia.py index d026f35d..84f15add 100644 --- a/bw2io/strategies/lcia.py +++ b/bw2io/strategies/lcia.py @@ -303,7 +303,7 @@ def add_subcategories(obj, mapping): ) for method in data: - already_have = {(obj["name"], obj["categories"]) for obj in method["exchanges"]} + already_have = {(obj["name"], tuple(obj["categories"])) for obj in method["exchanges"]} new_cfs = [] for obj in method["exchanges"]: @@ -313,7 +313,7 @@ def add_subcategories(obj, mapping): subcat_cfs = [ x for x in add_subcategories(obj, mapping) - if (x["name"], x["categories"]) not in already_have + if (x["name"], tuple(x["categories"])) not in already_have ] if subcat_cfs and remove and not obj.get("input"): obj["remove_me"] = True diff --git a/tests/ecospold2/ecospold2_extractor.py b/tests/ecospold2/ecospold2_extractor.py index 18de433e..729112a5 100644 --- a/tests/ecospold2/ecospold2_extractor.py +++ b/tests/ecospold2/ecospold2_extractor.py @@ -12,7 +12,7 @@ def test_extraction_without_synonyms(): "ei", ) expected = { - "comment": "Things and stuff and whatnot\nTechnology: typical technology for ze Germans!", + "comment": "Things and stuff and whatnot\nIncluded activities start: Includes start stuff\nIncluded activities end: Includes end stuff\nTechnology: typical technology for ze Germans!", "classifications": [ ("EcoSpold01Categories", "construction materials/concrete"), ( @@ -80,7 +80,7 @@ def test_extraction_without_synonyms(): "flow": "075e433b-4be4-448e-9510-9a5029c1ce94", "type": "biosphere", "chemical formula": "h2o2", - 'formula': 'does_it_hurt_when_dropped_on_foot * 2', + "formula": "does_it_hurt_when_dropped_on_foot * 2", "variable name": "it_is_boring_to_do_this_manually", "name": "Water", "classifications": {"CPC": []}, @@ -148,7 +148,7 @@ def test_extraction_with_synonyms(): "ei", ) expected = { - "comment": "Things and stuff and whatnot\nTechnology: typical technology for ze Germans!", + "comment": "Things and stuff and whatnot\nIncluded activities end: Includes some stuff\nTechnology: typical technology for ze Germans!", "classifications": [ ("EcoSpold01Categories", "construction materials/concrete"), ( diff --git a/tests/fixtures/ecospold2/00000_11111111-2222-3333-4444-555555555555_66666666-7777-8888-9999-000000000000.spold b/tests/fixtures/ecospold2/00000_11111111-2222-3333-4444-555555555555_66666666-7777-8888-9999-000000000000.spold index 37c5c3a6..7fff5870 100644 --- a/tests/fixtures/ecospold2/00000_11111111-2222-3333-4444-555555555555_66666666-7777-8888-9999-000000000000.spold +++ b/tests/fixtures/ecospold2/00000_11111111-2222-3333-4444-555555555555_66666666-7777-8888-9999-000000000000.spold @@ -4,8 +4,8 @@ concrete block production - - Includes some stuff + Includes start stuff + Includes end stuff Things and stuff and whatnot diff --git a/tests/strategies/lcia.py b/tests/strategies/lcia.py index 49ee4a4a..efc801d9 100644 --- a/tests/strategies/lcia.py +++ b/tests/strategies/lcia.py @@ -459,6 +459,21 @@ def test_match_subcategories_makes_copies(self): self.assertEqual(cf["amount"], 2) +def test_categories_as_list(): + """ issues/212 + """ + data = [ + { + "name": "Method 1", + "exchanges": [ + {"categories": ["air",], "name": "Emission", "unit": "kg", "amount": 1.0}, + ], + } + ] + biosphere_db_name = "example_biosphere" + match_subcategories(data, biosphere_db_name) # should pass without traceback + + def test_rationalize_method_names_no_remove_lt(): given = [ {"name": ("aw/o LT", "b", "c w/o LT")},