diff --git a/common/python/nomadcore/baseclasses.py b/common/python/nomadcore/baseclasses.py index a1148a4ae6683755ee85a20812c742b0197517aa..dd4b58d85fc93d92193bc4237c60313c56fa1c02 100644 --- a/common/python/nomadcore/baseclasses.py +++ b/common/python/nomadcore/baseclasses.py @@ -182,7 +182,7 @@ class ParserInterface(with_metaclass(ABCMeta, object)): if not self.main_parser: logger.error("The main parser has not been set up.") - self.main_parser.parse() + self.main_parser.parse(main_file) # If using a local backend, the results will have been saved to a # separate results dictionary which should be returned. @@ -310,8 +310,7 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)): caching backend. """ - def __init__(self, file_path, parser_context): - self.file_path = file_path + def __init__(self, parser_context): self.parser_context = parser_context self.backend = parser_context.caching_backend self.super_backend = parser_context.super_backend @@ -366,7 +365,7 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)): self.super_backend.fileOut.write("]\n") @abstractmethod - def parse(self): + def parse(self, filepath): """Used to do the actual parsing. Inside this function you should push the parsing results into the Caching backend, or directly to the superBackend. You will also have to open new sections, but remember @@ -398,20 +397,20 @@ class MainHierarchicalParser(AbstractBaseParser): onClose triggers, SimpleMatchers, caching levels, etc. """ - def __init__(self, file_path, parser_context): + def __init__(self, parser_context): """ Args: file_path: Path to the main file as a string. parser_context: The ParserContext object that contains various in-depth information about the parsing environment. """ - super(MainHierarchicalParser, self).__init__(file_path, parser_context) + super(MainHierarchicalParser, self).__init__(parser_context) self.root_matcher = None self.regexs = RegexService() self.cm = None self.super_context = self - def parse(self): + def parse(self, filepath): """Starts the parsing. By default uses the SimpleParser scheme, if you want to use something else or customize the process just override this method in the subclass. @@ -429,7 +428,7 @@ class MainHierarchicalParser(AbstractBaseParser): metainfo_units=self.parser_context.metainfo_units, superBackend=self.parser_context.super_backend, metaInfoToKeep=self.parser_context.metainfo_to_keep, - mainFile=self.parser_context.main_file) + mainFile=filepath) def startedParsing(self, fInName, parser): """Function is called when the parsing starts.