From f44f8ac2e201011bbce5b757b8535532c44d90f4 Mon Sep 17 00:00:00 2001 From: Michael Vinyard Date: Fri, 28 Feb 2025 22:49:28 -0700 Subject: [PATCH 1/3] small fixes --- ABCParse/__version__.py | 2 +- ABCParse/_abc_parse.py | 31 +++++++++++++++++-------------- ABCParse/_as_list.py | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ABCParse/__version__.py b/ABCParse/__version__.py index 485f44a..af0774b 100644 --- a/ABCParse/__version__.py +++ b/ABCParse/__version__.py @@ -1 +1 @@ -__version__ = "0.1.1" +__version__ = "0.1.2rc0" diff --git a/ABCParse/_abc_parse.py b/ABCParse/_abc_parse.py index b046814..c33ceb8 100644 --- a/ABCParse/_abc_parse.py +++ b/ABCParse/_abc_parse.py @@ -45,12 +45,12 @@ def __call__(self, x=4, y=5, z=3, *args, **kwargs): def _initialize_logger(self, level: str = "warning", file_path: str = logging._format.DEFAULT_LOG_FILEPATH) -> None: # Initialize logger with class name and logging parameters - self._logger = logging.get_logger( + self._cls_logger = logging.get_logger( name=self.__class__.__name__, level=level, file_path=file_path ) - self._logger.debug(f"Initializing {self.__class__.__name__}") + self._cls_logger.debug(f"Initializing {self.__class__.__name__}") def __build__(self, level: str = "warning", file_path: str = logging._format.DEFAULT_LOG_FILEPATH) -> None: self._PARAMS = {} @@ -59,7 +59,7 @@ def __build__(self, level: str = "warning", file_path: str = logging._format.DEF self._stored_public = [] self._initialize_logger(level, file_path) self._BUILT = True - self._logger.debug("Built internal structures") + self._cls_logger.debug("Built internal structures") def __set__( self, key: str, val: Any, public: List = [], private: List = [] @@ -69,10 +69,10 @@ def __set__( if (key in private) and (not key in public): self._stored_private.append(key) key = f"_{key}" - self._logger.debug(f"Setting private attribute: {key}") + self._cls_logger.debug(f"Setting private attribute: {key}") else: self._stored_public.append(key) - self._logger.debug(f"Setting public attribute: {key}") + self._cls_logger.debug(f"Setting public attribute: {key}") setattr(self, key, val) def __set_existing__(self, key: str, val: Any) -> None: @@ -87,19 +87,19 @@ def __set_existing__(self, key: str, val: Any) -> None: attr.update(val) setattr(self, key, attr) self._PARAMS.update(val) - self._logger.debug(f"Updated kwargs: {val}") + self._cls_logger.debug(f"Updated kwargs: {val}") elif passed_key == "args": attr = getattr(self, key) attr += val setattr(self, key, attr) self._PARAMS[passed_key] += val - self._logger.debug(f"Updated args: {val}") + self._cls_logger.debug(f"Updated args: {val}") else: self._PARAMS[passed_key] = val setattr(self, key, val) - self._logger.debug(f"Updated attribute {key}: {val}") + self._cls_logger.debug(f"Updated attribute {key}: {val}") @property def _STORED(self) -> List: @@ -110,11 +110,11 @@ def __setup_inputs__(self, kwargs, public, private, ignore) -> Tuple[List]: self.__build__() self._IGNORE += ignore - self._logger.debug(f"Setup inputs with ignore list: {self._IGNORE}") + self._cls_logger.debug(f"Setup inputs with ignore list: {self._IGNORE}") if len(public) > 0: private = list(kwargs.keys()) - self._logger.debug(f"Public attributes specified, setting all others as private") + self._cls_logger.debug(f"Public attributes specified, setting all others as private") return public, private @@ -142,13 +142,13 @@ def __parse__( """ public, private = self.__setup_inputs__(kwargs, public, private, ignore) - self._logger.debug(f"Parsing kwargs: {kwargs}") + self._cls_logger.debug(f"Parsing kwargs: {kwargs}") for key, val in kwargs.items(): if not key in self._IGNORE: self.__set__(key, val, public, private) - self._logger.info(f"Parsed {len(self._PARAMS)} parameters") + self._cls_logger.debug(f"Parsed {len(self._PARAMS)} parameters") def __update__( self, @@ -179,7 +179,7 @@ def __update__( ------- None """ - self._logger.debug(f"Updating with kwargs: {kwargs}") + self._cls_logger.debug(f"Updating with kwargs: {kwargs}") public, private = self.__setup_inputs__(kwargs, public, private, ignore) updated_count = 0 @@ -194,4 +194,7 @@ def __update__( self.__set__(key, val, public, private) new_count += 1 - self._logger.info(f"Updated {updated_count} existing parameters and added {new_count} new parameters") + self._cls_logger.debug(f"Updated {updated_count} existing parameters and added {new_count} new parameters") + + def __repr__(self) -> str: + return "ABCParse.ABCParse" \ No newline at end of file diff --git a/ABCParse/_as_list.py b/ABCParse/_as_list.py index b57822a..cc4a2eb 100644 --- a/ABCParse/_as_list.py +++ b/ABCParse/_as_list.py @@ -87,7 +87,7 @@ def __call__( if not self._target_type is None: assert self.validated_target_types, "Not all values match the target type" - self._logger.info(f"Validated {len(self.list_values)} values against target type(s)") + self._logger.debug(f"Validated {len(self.list_values)} values against target type(s)") return self.list_values @@ -116,5 +116,5 @@ def as_list( _logger.debug(f"as_list called with input: {input}, target_type: {target_type}") _as_list = AsList() result = _as_list(input=input, target_type=target_type, *args, **kwargs) - _logger.info(f"Converted to list with {len(result)} elements") + _logger.debug(f"Converted to list with {len(result)} elements") return result From 029c8999317595ec56a2b56060a73248aa845bf2 Mon Sep 17 00:00:00 2001 From: Michael Vinyard Date: Fri, 28 Feb 2025 22:49:45 -0700 Subject: [PATCH 2/3] update version --- ABCParse/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ABCParse/__version__.py b/ABCParse/__version__.py index af0774b..b3f4756 100644 --- a/ABCParse/__version__.py +++ b/ABCParse/__version__.py @@ -1 +1 @@ -__version__ = "0.1.2rc0" +__version__ = "0.1.2" From 81b1c2599695baa26b844a9a8bb49f5b39b83f6f Mon Sep 17 00:00:00 2001 From: Michael Vinyard Date: Fri, 28 Feb 2025 22:52:13 -0700 Subject: [PATCH 3/3] update tests to match syntax --- tests/test_ABCParse.py | 2 +- tests/test_logging.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_ABCParse.py b/tests/test_ABCParse.py index 73f29f3..f134bac 100644 --- a/tests/test_ABCParse.py +++ b/tests/test_ABCParse.py @@ -24,7 +24,7 @@ def test_build(self) -> None: self.assertIn("__class__", self.parser._IGNORE) self.assertEqual(self.parser._stored_private, []) self.assertEqual(self.parser._stored_public, []) - self.assertIsInstance(self.parser._logger, ABCParse.logging.ABCLogger) + self.assertIsInstance(self.parser._cls_logger, ABCParse.logging.ABCLogger) def test_set(self) -> None: """Test the __set__ method for setting attributes.""" diff --git a/tests/test_logging.py b/tests/test_logging.py index 957f0c5..645446a 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -133,10 +133,10 @@ def test_abc_parse_logging(self) -> None: parser.__build__() try: # Test that the parser logs correctly - parser._logger.info("Test message from ABCParse") + parser._cls_logger.info("Test message from ABCParse") # Ensure logger is closed to flush buffers - parser._logger.close() + parser._cls_logger.close() # Verify the message was logged to file @@ -146,7 +146,7 @@ def test_abc_parse_logging(self) -> None: finally: # Ensure logger is closed even if assertions fail if hasattr(parser, '_logger'): - parser._logger.close() + parser._cls_logger.close() finally: # Clean up the temporary file try: