Skip to content

Commit

Permalink
fix: updated pydantic version and allowing dicts as arguments to conv…
Browse files Browse the repository at this point in the history
…ert_ilcd
  • Loading branch information
ocni-dtu committed Feb 16, 2024
1 parent 4f38790 commit 34fdaa9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/python/src/epdx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
__all__ = epdx.__all__


def convert_ilcd(data: str, *, as_type: str = "dict"):
def convert_ilcd(data: str | dict, *, as_type: str = "dict"):
"""
Converts a json formatted ILCD+EPD data into EPDx
The EPDx data can either be returned as a string, a dict or a Pydantic class.
"""

if isinstance(data, dict):
data = json.dumps(data)

try:
_epd = epdx._convert_ilcd(data)
except Exception as err:
Expand Down
Binary file modified packages/python/src/epdx/epdx.abi3.so
Binary file not shown.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ authors = [
{ name = "Christian Kongsgaard", email = "christian@kongsgaard.eu" },
]

dependencies = [
"pydantic >=2.0.0"
]

[project.optional-dependencies]
doc = [
"mkdocs-material >=8.1.4,<9.0.0",
"mdx-include >=1.4.1,<2.0.0",
]
codegen = [
"pydantic >=1.8.2,<2.0.0",
"datamodel-code-generator",
]
tests = [
Expand Down
2 changes: 1 addition & 1 deletion src/epd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn collect_from_exchanges(exchanges: &Vec<Exchange>) -> (Unit, Vec<Conversion>,
_description if _description == "Use of renewable primary energy (PERE)" => pere = impact_value,
_description if _description == "Use of renewable primary energy resources used as raw materials (PERM)" => perm = impact_value,
_description if _description == "Total use of renewable primary energy resources (PERT)" => pert = impact_value,
_description if _description == "Use of non renewable primary energy (PENRE)" => pert = impact_value,
_description if _description == "Use of non renewable primary energy (PENRE)" => penre = impact_value,
_description if _description == "Use of non renewable primary energy resources used as raw materials (PENRM)" => penrm = impact_value,
_description if _description == "Total use of non renewable primary energy resource (PENRT)" => penrt = impact_value,
_description if _description == "Use of secondary material (SM)" => sm = impact_value,
Expand Down

0 comments on commit 34fdaa9

Please sign in to comment.