Commit 8c2e56b0 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Switched to FairdiParser with archive not backend.

parent 2c8b7763
......@@ -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):
name='parsers/vasp', code_name='VASP', code_homepage='',
......@@ -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 =
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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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()
Supports Markdown
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