diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a6cb8b615eb7a44af58c9563596ab6264ef6dbe6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# use glob syntax. +syntax: glob +*.ser +*.class +*~ +*.bak +#*.off +*.old +*.pyc +*.bk +*.swp +.DS_Store + +# logging files +detailed.log + +# eclipse conf file +.settings +.classpath +.project +.manager +.scala_dependencies + +# idea +.idea +*.iml + +# building +target +build +null +tmp* +temp* +dist +test-output +build.log + +# other scm +.svn +.CVS +.hg* + +# switch to regexp syntax. +# syntax: regexp +# ^\.pc/ + +#SHITTY output not in target directory +build.log + +#emacs TAGS +TAGS + +lib/ +env/ diff --git a/parser/sample-parser/sample_parser.py b/parser/sample-parser/sample_parser.py index 0795d0d8c7b9b829e9018c20ed592076330793cd..d21c238e358e3fc0b0a0964a9635c475e76f08b6 100644 --- a/parser/sample-parser/sample_parser.py +++ b/parser/sample-parser/sample_parser.py @@ -1,8 +1,25 @@ +from builtins import object import setup_paths from nomadcore.simple_parser import SimpleMatcher, mainFunction from nomadcore.local_meta_info import loadJsonFile, InfoKindEl import os, sys, json +class SampleContext(object): + """context for the sample parser""" + + def __init__(self): + self.parser = None + + def initialize_values(self): + """allows to reset values if the same superContext is used to parse different files""" + pass + + def startedParsing(self, path, parser): + """called when parsing starts""" + self.parser = parser + # allows to reset values if the same superContext is used to parse different files + self.initialize_values() + # description of the input mainFileDescription = SimpleMatcher(name = 'root', weak = True, @@ -31,4 +48,5 @@ metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__f metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None) if __name__ == "__main__": - mainFunction(mainFileDescription, metaInfoEnv, parserInfo) + superContext = SampleContext() + mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext)