Skip to content

Commit 14bd934

Browse files
authored
fix: LCIMethodAndAllocation missing "other" field (#86)
* fix: Fixes problems with no "other" field in LCIMethodAndAllocation and thereby subtype in ILCD data. Resolves #85 * ci: Publishing Python without attestations
1 parent 9bcb2e1 commit 14bd934

5 files changed

Lines changed: 3900 additions & 7 deletions

File tree

.github/workflows/publish_python.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ jobs:
7979

8080
- name: Publish to PyPI
8181
uses: pypa/gh-action-pypi-publish@release/v1
82+
with:
83+
attestations: false

modules/convert/src/ilcd/ilcd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub struct ReferenceToLCIAMethodDataSet {
182182
#[derive(Deserialize)]
183183
#[serde(rename_all = "camelCase")]
184184
pub struct LCIMethodAndAllocation {
185-
pub other: Anies,
185+
pub other: Option<Anies>,
186186
}
187187

188188
#[derive(Deserialize)]

modules/convert/src/ilcd/parse.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ilcd::ilcd::{DataSetName, Exchange, LCIAResult, ModuleAnie, ILCD};
1+
use crate::ilcd::ilcd::{Anie, DataSetName, Exchange, LCIAResult, ModuleAnie, ILCD};
22
use chrono::NaiveDate;
33
use lcax_core::country::Country;
44
use lcax_core::utils::get_version;
@@ -26,14 +26,21 @@ pub fn parse_ilcd(data: &str) -> Result<EPD, Error> {
2626
}
2727

2828
fn epd_from_ilcd(ilcd_epd: ILCD) -> Result<EPD, Error> {
29-
let subtype = ilcd_epd
29+
let generic_anie = Anie {
30+
value: Some("Generic".to_string()),
31+
name: "subType".to_string(),
32+
};
33+
let subtype = match &ilcd_epd
3034
.modelling_and_validation
3135
.lci_method_and_allocation
3236
.other
33-
.anies
34-
.iter()
35-
.find(|&anie| anie.name == "subType")
36-
.unwrap();
37+
{
38+
Some(other) => match other.anies.iter().find(|&anie| anie.name == "subType") {
39+
Some(subtype) => subtype.clone(),
40+
None => &generic_anie,
41+
},
42+
None => &generic_anie,
43+
};
3744

3845
let mut impacts = collect_from_lcia_result(&ilcd_epd.lcia_results.lcia_result);
3946

0 commit comments

Comments
 (0)