diff --git a/opencsp/common/lib/file/AttributesManager.py b/opencsp/common/lib/file/AttributesManager.py index 2a500bca0..f7cd4f0cd 100644 --- a/opencsp/common/lib/file/AttributesManager.py +++ b/opencsp/common/lib/file/AttributesManager.py @@ -80,27 +80,7 @@ def get_parser( if parser_class in self.generic_parsers: return self.generic_parsers[parser_class] - # find all parsers that are a subclass of the requested parser_class - subclass_parsers: list[aap.AbstractAttributeParser] = [] - for parser in self.parsers: - if isinstance(parser, parser_class): - subclass_parsers.append(parser) - if len(subclass_parsers) == 1: - return subclass_parsers[0] - if len(subclass_parsers) == 0: - if error_on_not_found: - lt.error_and_raise( - RuntimeError, - "Programmer error in AttributesManager.get_parser(): " - + f"there is an unregistered parser class {parser_class}! All AbstractAttributeParsers should " - + "register themselves with RegisterClass() when their file is imported to prevent this error.", - ) - else: - return None - - # more than one subclass found, just return the first one - lt.debug(f"In AttributesManager.get_parser(): found more than one parser matching parser class {parser_class}") - return subclass_parsers[0] + return None def set_parser(self, parser: aap.AbstractAttributeParser): """Sets the given parser as the default parser for the given class.""" diff --git a/opencsp/common/lib/render/ImageAttributeParser.py b/opencsp/common/lib/render/ImageAttributeParser.py index dab712209..2b37f18f9 100644 --- a/opencsp/common/lib/render/ImageAttributeParser.py +++ b/opencsp/common/lib/render/ImageAttributeParser.py @@ -69,7 +69,7 @@ def __init__( attributes_file = os.path.join(opath, f"{oname}.txt") self._previous_attr = am.AttributesManager() self._previous_attr.load(attributes_file) - except: + except Exception as e: pass if self._previous_attr != None: prev_image_attr: ImageAttributeParser = self._previous_attr.get_parser(self.__class__) diff --git a/opencsp/common/lib/render/test/test_ImageAttributeParser.py b/opencsp/common/lib/render/test/test_ImageAttributeParser.py index 91bc498ea..00a9ff4ae 100644 --- a/opencsp/common/lib/render/test/test_ImageAttributeParser.py +++ b/opencsp/common/lib/render/test/test_ImageAttributeParser.py @@ -49,7 +49,6 @@ def test_has_contents(self): parser = iap.ImageAttributeParser(notes="") self.assertEqual(True, parser.has_contents()) - @pytest.mark.skip("See https://github.com/sandialabs/OpenCSP/issues/3") def test_with_attrfile(self): """Load all values from the associated attributes file. Use the new current_image_source value.""" parser = iap.ImageAttributeParser(current_image_source=self.img_file) diff --git a/opencsp/common/lib/tool/file_tools.py b/opencsp/common/lib/tool/file_tools.py index 639d4fb34..1f5a3dffb 100755 --- a/opencsp/common/lib/tool/file_tools.py +++ b/opencsp/common/lib/tool/file_tools.py @@ -35,9 +35,11 @@ def path_components(input_dir_body_ext: str): See also: body_ext_given_file_dir_body_ext() """ + dir = os.path.dirname(input_dir_body_ext) body_ext = os.path.basename(input_dir_body_ext) body, ext = os.path.splitext(body_ext) + return dir, body, ext