Commit 45edbd90 authored by Popov, Igor (igop)'s avatar Popov, Igor (igop)
Browse files

Adopting wien2k parser to NOMAD-FAIR

parent f768736e
......@@ -52,3 +52,6 @@ TAGS
lib/
env/
*egg-info
from wien2kparser.wien2k_parser import Wien2kParser
\ No newline at end of file
from builtins import object
import setup_paths
from wien2kparser import setup_paths
import numpy as np
from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json, logging
import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2
from wien2kparser import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2
################################################################
......@@ -277,6 +277,36 @@ parserInfo = {
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/wien2k.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
class Wien2kParser:
""" A proper class envolop for running this parser from within python. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
logging.warn('something is wrong')
logger = logging.getLogger(__name__)
logger.warn(...)
def parse(self, mainfile):
from unittest.mock import patch
# _logging.getLogger('nomadcore').setLevel(_logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]):
mainFunction(
mainFileDescription,
metaInfoEnv,
parserInfo,
superContext=Wien2kContext(),
superBackend=backend)
return backend
def setup_logger(self, new_logger):
if hasattr(new_logger, 'bind'):
# tell tests about received logger
new_logger.debug('received logger')
if __name__ == "__main__":
superContext = Wien2kContext()
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext)
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import setup_paths
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
# Copyright 2015-2018 Lorenzo Pardini
#
# 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.
from setuptools import setup, find_packages
def main():
setup(
name='wien2kparser',
version='0.1',
description='NOMAD parser implementation for Wien2k.',
license='APACHE 2.0',
package_dir={'': 'parser'},
packages=find_packages('parser'),
install_requires=[
'nomadcore'
],
)
if __name__ == '__main__':
main()
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