From b6c217b202694768dfb76742314ef57693145c0d Mon Sep 17 00:00:00 2001 From: Chris Mutel Date: Wed, 27 Nov 2024 11:00:45 +0100 Subject: [PATCH] Fix #282 --- bw2io/extractors/ecospold2.py | 9 +++------ tests/ecospold2/ecospold2_extractor.py | 16 ++++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bw2io/extractors/ecospold2.py b/bw2io/extractors/ecospold2.py index 1e98f31f..e91f8b3c 100644 --- a/bw2io/extractors/ecospold2.py +++ b/bw2io/extractors/ecospold2.py @@ -575,12 +575,9 @@ def extract_exchange(cls, exc): "type": kind, "name": exc.name.text, "classifications": { - "CPC": [ - o.classificationValue.text - for o in exc.iterchildren() - if "classification" in o.tag - and o.classificationSystem.text == "CPC" - ] + o.classificationSystem.text: o.classificationValue.text + for o in exc.iterchildren() + if o.tag == "{http://www.EcoInvent.org/EcoSpold02}classification" }, "production volume": float(exc.get("productionVolumeAmount") or 0), "properties": cls.extract_properties(exc), diff --git a/tests/ecospold2/ecospold2_extractor.py b/tests/ecospold2/ecospold2_extractor.py index 780bc362..4b60b352 100644 --- a/tests/ecospold2/ecospold2_extractor.py +++ b/tests/ecospold2/ecospold2_extractor.py @@ -29,7 +29,8 @@ def test_extraction_without_synonyms(): "type": "technosphere", "name": "clay pit infrastructure", "classifications": { - "CPC": ["53269: Other constructions for manufacturing"] + "By-product classification": "allocatable product", + "CPC": "53269: Other constructions for manufacturing", }, "production volume": 0.0, "properties": {}, @@ -54,7 +55,8 @@ def test_extraction_without_synonyms(): "type": "production", "name": "concrete block", "classifications": { - "CPC": ["37510: Non-refractory mortars and concretes"] + "By-product classification": "allocatable product", + "CPC": "37510: Non-refractory mortars and concretes", }, "production volume": 42.0, "properties": { @@ -84,7 +86,7 @@ def test_extraction_without_synonyms(): "CAS number": "7732-18-5", "variable name": "it_is_boring_to_do_this_manually", "name": "Water", - "classifications": {"CPC": []}, + "classifications": {}, "production volume": 0.0, "properties": { "water in wet mass": { @@ -166,7 +168,8 @@ def test_extraction_with_synonyms(): "type": "technosphere", "name": "clay pit infrastructure", "classifications": { - "CPC": ["53269: Other constructions for manufacturing"] + "By-product classification": "allocatable product", + "CPC": "53269: Other constructions for manufacturing", }, "production volume": 0.0, "properties": {}, @@ -191,7 +194,8 @@ def test_extraction_with_synonyms(): "type": "production", "name": "concrete block", "classifications": { - "CPC": ["37510: Non-refractory mortars and concretes"] + "By-product classification": "allocatable product", + "CPC": "37510: Non-refractory mortars and concretes", }, "production volume": 42.0, "properties": { @@ -220,8 +224,8 @@ def test_extraction_with_synonyms(): "chemical formula": "h2o2", "formula": "does_it_hurt_when_dropped_on_foot * 2", "CAS number": "7732-18-5", + "classifications": {}, "variable name": "it_is_boring_to_do_this_manually", - "classifications": {"CPC": []}, "production volume": 0.0, "properties": { "water in wet mass": {