Skip to content
Snippets Groups Projects
Commit 62c6d3d8 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Modified classes to take in the filepath in the parse()-function instead of the constructor.

parent 299ecfdd
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment