From fcbfca597a76c2c885d2db2f682089b775932008 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Wed, 12 Jun 2024 15:10:02 -0400 Subject: [PATCH] Added hook to structured_data (row_reader_hook) for integration testing purposes. --- CHANGELOG.rst | 1 + dcicutils/structured_data.py | 4 ++++ pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 79ac85da4..09c73c29f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,7 @@ Change Log ====== * Changes related to pyinstaller experimentation for smaht-submitr. Mostly changing calls to exit to sys.exit; and related license_utils change. +* Added hook to structured_data (row_reader_hook) for integration testing purposes. 8.10.0 diff --git a/dcicutils/structured_data.py b/dcicutils/structured_data.py index c9b895849..2d058a588 100644 --- a/dcicutils/structured_data.py +++ b/dcicutils/structured_data.py @@ -57,6 +57,7 @@ def __init__(self, file: Optional[str] = None, portal: Optional[Union[VirtualApp ref_lookup_nocache: bool = False, norefs: bool = False, merge: bool = False, progress: Optional[Callable] = None, + row_reader_hook: Optional[Callable] = None, debug_sleep: Optional[str] = None) -> None: self._progress = progress if callable(progress) else None self._data = {} @@ -75,6 +76,7 @@ def __init__(self, file: Optional[str] = None, portal: Optional[Union[VirtualApp self._autoadd_properties = autoadd if isinstance(autoadd, dict) and autoadd else None self._norefs = True if norefs is True else False self._merge = True if merge is True else False # New merge functionality (2024-05-25) + self._row_reader_hook = row_reader_hook if callable(row_reader_hook) else None # Testing support (2024-06-12) self._debug_sleep = None if debug_sleep: try: @@ -377,6 +379,8 @@ def _load_reader(self, reader: RowReader, type_name: str) -> None: structured_row_template = _StructuredRowTemplate(reader.header, schema) structured_row = structured_row_template.create_row() for column_name, value in row.items(): + if self._row_reader_hook: + value = self._row_reader_hook(reader.sheet_name, column_name, value) structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number) if self._autoadd_properties: self._add_properties(structured_row, self._autoadd_properties, schema) diff --git a/pyproject.toml b/pyproject.toml index 776dbab77..5d5d86100 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.10.0.1b2" # TODO: To become 8.10.1 +version = "8.10.0.1b3" # TODO: To become 8.10.1 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"