Skip to content

Commit f03bd7f

Browse files
fix: Agilent OpenLab CDS - use bytes to read zip file instead of file name (#1021)
Allotropy parsers must read from bytes, not from local files, as the interface allows passing in bytes.
1 parent a39b8bc commit f03bd7f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def _get_matching_filenames(zip_ref: zipfile.ZipFile, pattern: str) -> list[str]
273273
]
274274

275275

276-
def decode_data(input_path: str) -> dict[str, Any]:
276+
def decode_data(input_bytes: IO[bytes]) -> dict[str, Any]:
277277
"""
278278
decoded the files in input folder path and returns a structured data
279279
:param input_path: input folder path
@@ -284,7 +284,7 @@ def decode_data(input_path: str) -> dict[str, Any]:
284284
total_injection_chromatogram_details: list[dict[str, Any]] = []
285285
total_peak_details: list[dict[str, Any]] = []
286286

287-
with zipfile.ZipFile(input_path, "r") as zip_ref:
287+
with zipfile.ZipFile(input_bytes) as zip_ref:
288288
acaml_path = next(iter(_get_matching_filenames(zip_ref, ".*acaml")))
289289
with zip_ref.open(acaml_path) as acaml_file_data:
290290
acaml_file_content = acaml_file_data.read().decode("utf-8-sig")

src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AgilentOpenLabCDSParser(VendorParser[Data, Model]):
2626
SCHEMA_MAPPER = Mapper
2727

2828
def create_data(self, named_file_contents: NamedFileContents) -> Data:
29-
structured_data = decode_data(named_file_contents.original_file_path)
29+
structured_data = decode_data(named_file_contents.get_bytes_stream())
3030
return Data(
3131
metadata=create_metadata(structured_data, named_file_contents),
3232
measurement_groups=[create_measurement_groups(structured_data)],

0 commit comments

Comments
 (0)