scalainterface.py 1.61 KB
Newer Older
1
2
3
"""
This is the access point to the parser for the scala layer in the nomad project.
"""
4
import setup_paths
5
import os
6
from cp2kparser.parsing.versions.cp2k262.outputparser import CP2KOutputParser
7
8
9
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.simple_parser import mainFunction

10
# This is what gets run when the scala layer calls for this parser. Currently
11
12
13
14
# only the outputparser is used because the scala layer doesn't support
# auxiliary files. Also the version identification is skipped and the structure
# used in CP2K 2.6.2 is assumed.
if __name__ == "__main__":
15

16
    # Get the outputparser class
17
    outputparser = CP2KOutputParser(None, None)
18
19

    # Setup the metainfos
20
    metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../../../nomad-meta-info/meta_info/nomad_meta_info/cp2k.nomadmetainfo.json"))
21
22
23
24
25
26
    metaInfoEnv, warnings = loadJsonFile(filePath=metaInfoPath, dependencyLoader=None, extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS, uri=None)

    # Parser info
    parserInfo = {'name': 'cp2k-parser', 'version': '1.0'}

    # Adjust caching of metadata
27
    cachingLevelForMetaName = outputparser.caching_level_for_metaname
28
29
30
31
32
33

    # Supercontext is where the objet where the callback functions for
    # section closing are found
    superContext = outputparser

    # Main file description is the SimpleParser tree
34
    mainFileDescription = outputparser.root_matcher
35
36
37

    # Use the main function from nomadcore
    mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext=superContext, cachingLevelForMetaName=cachingLevelForMetaName, onClose={})