Commit b641bf93 authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

added python sample files

parent 677a04df
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 OrcaContext(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"""
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
# description of the input
mainFileDescription = SimpleMatcher(name = 'root',
weak = True,
startReStr = "",
subMatchers = [
SimpleMatcher(name = 'newRun',
startReStr = r"\s*# SampleParser #\s*",
repeats = True,
required = True,
forwardMatch = True,
sections = ['section_run'],
subMatchers = [
SimpleMatcher(name = 'header',
startReStr = r"\s*# SampleParser #\s*")
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
parserInfo = {
"name": "sample_parser",
"version": "1.0"
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/orca.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
if __name__ == "__main__":
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext=OrcaContext())
import sys, os, os.path
baseDir = os.path.dirname(os.path.abspath(__file__))
commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python"))
if not commonDir in sys.path:
sys.path.insert(0, commonDir)
......@@ -26,7 +26,7 @@ object OrcaParser extends SimpleExternalParserGenerator(
cmd = Seq(DefaultPythonInterpreter.python2Exe(), "${envDir}/parsers/orca/parser/parser-orca/",
"--uri", "${mainFileUri}", "${mainFilePath}"),
resList = Seq(
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment