-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Labels
parserIssues related to the parser layerIssues related to the parser layer
Description
We want a refactored parser using the new data model (available on https://github.com/spdx/tools-python/tree/refactor-python-tools).
Possible basic interface (maybe extract an abstract base class later) as follows. The parser class should use composition instead of inheritance.
class JsonParser:
creation_info_parser: CreationInfoParser
package_parser: PackageParser
file_parser: FileParser
<...>
def parse(self, filename: str) -> Document:
logger = Logger()
with open(filename) as file:
input_doc_as_dict = json.load(file)
document: Document = creation_info_parser.parse(input_doc_as_dict, logger)
document.packages = package_parser.parse(input_doc_as_dict.get("packages"), logger)
<...>
if logger.has_errors():
raise SpdxParsingError(logger.get_errors())
return document
Metadata
Metadata
Assignees
Labels
parserIssues related to the parser layerIssues related to the parser layer