Skip to content
Snippets Groups Projects
Commit 8c2e56b0 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Switched to FairdiParser with archive not backend.

parent 2c8b7763
Branches
Tags
No related merge requests found
......@@ -18,13 +18,15 @@ import gzip
import bz2
import lzma
from nomad.datamodel import EntryArchive
from .metainfo import m_env
from vaspparser.parser_vasprun import VasprunContext, XmlParser, parser_info
from nomad.parsing.parser import MatchingParser
from nomad.parsing.parser import FairdiParser
from vaspparser.parser_outcar import VaspOutcarParser
class VASPParser(MatchingParser):
class VASPParser(FairdiParser):
def __init__(self):
super().__init__(
name='parsers/vasp', code_name='VASP', code_homepage='https://www.vasp.at/',
......@@ -38,7 +40,7 @@ class VASPParser(MatchingParser):
supported_compressions=['gz', 'bz2', 'xz']
)
def run(self, filepath, logger=None):
def parse(self, filepath, archive, logger=None):
self._metainfo_env = m_env
super_context = VasprunContext(logger=logger)
......@@ -53,5 +55,4 @@ class VASPParser(MatchingParser):
elif filepath.endswith('.xz'):
open_file = lzma.open
parser.parse(os.path.abspath(filepath), open_file(filepath, 'rt'))
return parser.root_section
parser.parse(os.path.abspath(filepath), open_file(filepath, 'rt'), archive)
# Copyright 2016-2018 Markus Scheidgen
# 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
import json
from vaspparser import VASPParser
if __name__ == "__main__":
archive = VASPParser.main(sys.argv[1])
json.dump(archive.m_to_dict(), sys.stdout, indent=2)
\ No newline at end of file
......@@ -954,13 +954,13 @@ class XmlParser(object):
self.tagSections = {}
self.metainfo_env = metainfo_env
def parse(self, main_file_uri, f_in):
def parse(self, main_file_uri, f_in, archive):
if self.path:
raise Exception(
"Parse of %s called with non empty path, parse already in progress?" % main_file_uri)
self.main_file_uri = main_file_uri
self.f_in = f_in
self.root_section = msection_run()
self.root_section = archive.m_create(msection_run)
self.super_context.parser = self
# there are invalid characters like esc in the files, we do not want to crash on them
xml_parser = MyXMLParser()
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment