Commits (2)
......@@ -2471,10 +2471,6 @@ def get_cachingLevelForMetaName(metaInfoEnv):
return cachingLevelForMetaName
import nomad_meta_info
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(nomad_meta_info.__file__)), "castep.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
class CastepParser():
""" A proper class envolop for running this parser from within python. """
def __init__(self, backend, **kwargs):
......@@ -2484,13 +2480,13 @@ class CastepParser():
from unittest.mock import patch
logging.info('castep parser started')
logging.getLogger('nomadcore').setLevel(logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
backend = self.backend_factory("castep.nomadmetainfo.json")
with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]):
mainFunction(
mainFileDescription=build_CastepMainFileSimpleMatcher(),
metaInfoEnv=metaInfoEnv,
metaInfoEnv=None,
parserInfo = {'name':'castep-parser', 'version': '1.0'},
cachingLevelForMetaName = get_cachingLevelForMetaName(metaInfoEnv),
cachingLevelForMetaName = get_cachingLevelForMetaName(backend.metaInfoEnv()),
superContext=CastepParserContext(),
superBackend=backend,
defaultSectionCachingLevel = True)
......@@ -2505,8 +2501,8 @@ def main():
"""
# get main file description
CastepMainFileSimpleMatcher = build_CastepMainFileSimpleMatcher()
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/castep.nomadmetainfo.json
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../../nomad-meta-info/meta_info/nomad_meta_info/castep.nomadmetainfo.json"))
# loading metadata from nomad-meta-info/metainfo/castep.nomadmetainfo.json
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../../nomad-meta-info/metainfo/castep.nomadmetainfo.json"))
metaInfoEnv = get_metaInfo(metaInfoPath)
# set parser info
parserInfo = {'name':'castep-parser', 'version': '1.0'}
......
import sys
from nomad.metainfo import Environment
from nomad.metainfo.legacy import LegacyMetainfoEnvironment
import castepparser.metainfo.castep
import nomad.datamodel.metainfo.common
import nomad.datamodel.metainfo.public
import nomad.datamodel.metainfo.general
m_env = LegacyMetainfoEnvironment()
m_env.m_add_sub_section(Environment.packages, sys.modules['castepparser.metainfo.castep'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.common'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.public'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.general'].m_package) # type: ignore
This diff is collapsed.
# Copyright 2015-2018 Martina Stella, Massimo Riello, Fawzi Mohamed, Ankit Kariryaa
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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)