Commit b795e079 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen

add boilerplate stuff

parent bf71e6b4
from __future__ import print_function
import os
import sys
import setup_paths
import re
import numpy as np
from ase import Atoms
from ase.spacegroup import crystal
#from ase.data import chemical_symbols
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion.unit_conversion \
import register_userdefined_quantity, convert_unit
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/molcas.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath=metaInfoPath,
dependencyLoader=None,
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None)
parser_info = {'name': 'molcas-parser', 'version': '1.0'}
class MolcasContext(object):
def startedParsing(self, fname, parser):
pass
context = MolcasContext()
mainFileDescription = SM(
name='root',
weak=True,
startReStr='',
fixedStartValues={'program_name': 'Molcas'},
sections=['section_run'],
subMatchers=[])
def main(**kwargs):
mainFunction(mainFileDescription=mainFileDescription,
metaInfoEnv=metaInfoEnv,
parserInfo=parser_info,
cachingLevelForMetaName={},
superContext=context,
**kwargs)
if __name__ == '__main__':
main()
../../../../nomad-meta-info/meta_info/nomad_meta_info
\ No newline at end of file
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)
package eu.nomad_lab.parsers
import eu.{ nomad_lab => lab }
import eu.nomad_lab.DefaultPythonInterpreter
import org.{ json4s => jn }
import scala.collection.breakOut
object MolcasParser extends SimpleExternalParserGenerator(
name = "MolcasParser",
parserInfo = jn.JObject(
("name" -> jn.JString("MolcasParser")) ::
("parserId" -> jn.JString("MolcasParser" + lab.MolcasVersionInfo.version)) ::
("versionInfo" -> jn.JObject(
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
case (k, v) => k -> jn.JString(v.toString)
}(breakOut): List[(String, jn.JString)])) ::
(lab.MolcasVersionInfo.toMap.map {
case (key, value) =>
(key -> jn.JString(value.toString))
}(breakOut): List[(String, jn.JString)])
)) :: Nil
),
mainFileTypes = Seq("text/.*"),
mainFileRe = """Regex
for
molcas
mainfile
""".r,
cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/parsers/molcas/parser/parser-molcas/main.py",
"--uri", "${mainFileUri}", "${mainFilePath}"),
resList = Seq(
"parser-molcas/main.py",
"parser-molcas/setup_paths.py",
"nomad_meta_info/public.nomadmetainfo.json",
"nomad_meta_info/common.nomadmetainfo.json",
"nomad_meta_info/meta_types.nomadmetainfo.json",
"nomad_meta_info/molcas.nomadmetainfo.json"
) ++ DefaultPythonInterpreter.commonFiles(),
dirMap = Map(
"parser-molcas" -> "parsers/molcas/parser/parser-molcas",
"nomad_meta_info" -> "nomad-meta-info/meta_info/nomad_meta_info",
"python" -> "python-common/common/python/nomadcore"
) ++ DefaultPythonInterpreter.commonDirMapping(),
metaInfoEnv = Some(lab.meta.KnownMetaInfoEnvs.molcas)
)
package eu.nomad_lab.parsers
import eu.nomad_lab.{ parsers, DefaultPythonInterpreter }
import org.scalacheck.Properties
import org.specs2.mutable.Specification
import org.{ json4s => jn }
object MolcasParserSpec extends Specification {
"MolcasParserTest" >> {
"test example1.got " >> {
"test with json-events" >> {
ParserRun.parse(MolcasParser, "parsers/molcas/test/examples/outputs/example1.got", "json-events") must_== ParseResult.ParseSuccess
}
"test with json" >> {
ParserRun.parse(MolcasParser, "parsers/molcas/test/examples/outputs/example1.got", "json") must_== ParseResult.ParseSuccess
}
}
}
}
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