Commit 3ca57695 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added minimal outcar parser.

parent 1336a460
Pipeline #43296 passed with stages
in 17 minutes and 45 seconds
......@@ -57,10 +57,11 @@ based on NOMAD-coe's *python-common* module.
"""
from nomad.parsing.backend import AbstractParserBackend, LocalBackend, LegacyLocalBackend, JSONStreamWriter, BadContextURI, WrongContextState
from nomad.parsing.parser import Parser, LegacyParser
from nomad.parsing.parser import Parser, LegacyParser, VaspOutcarParser
from nomad.parsing.artificial import TemplateParser, GenerateRandomParser, ChaosParser
from nomad.dependencies import dependencies_dict as dependencies
parsers = [
GenerateRandomParser(),
TemplateParser(),
......@@ -76,6 +77,12 @@ parsers = [
r'?\s*<i name="program" type="string">\s*vasp\s*</i>'
r'?')
),
VaspOutcarParser(
python_git=dependencies['parsers/vasp'],
parser_class_name='vaspparser.VaspOutcarParser',
main_file_re=r'^OUTCAR(\.[^\.]*)?$',
main_contents_re=(r'^\svasp\..*$')
),
LegacyParser(
python_git=dependencies['parsers/exciting'],
parser_class_name='excitingparser.ExcitingParser',
......
......@@ -20,6 +20,8 @@ import importlib
import inspect
from unittest.mock import patch
import logging
import os.path
import glob
from nomad.parsing.backend import LocalBackend
from nomad.dependencies import PythonGit
......@@ -132,3 +134,24 @@ class LegacyParser(Parser):
def __repr__(self):
return self.python_git.__repr__()
class VaspOutcarParser(LegacyParser):
"""
LegacyParser that only matches mailfiles, if there is no .xml in the
same directory, i.e. to use the VASP OUTCAR parser in absence of .xml
output file.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.name = 'parsers/vaspoutcar'
def is_mainfile(self, filename: str, *args, **kwargs) -> bool:
is_mainfile = super().is_mainfile(filename, *args, **kwargs)
if is_mainfile:
os.path.dirname(filename)
if len(glob.glob('%s/*.xml*' % filename)) > 0:
return False
return is_mainfile
This diff is collapsed.
......@@ -30,6 +30,7 @@ parser_examples = [
('parsers/exciting', 'tests/data/parsers/exciting/Ag/INFO.OUT'),
('parsers/exciting', 'tests/data/parsers/exciting/GW/INFO.OUT'),
('parsers/vasp', 'tests/data/parsers/vasp.xml'),
('parsers/vaspoutcar', 'tests/data/parsers/vasp_outcar/OUTCAR'),
('parsers/fhi-aims', 'tests/data/parsers/aims.out'),
('parsers/cp2k', 'tests/data/parsers/cp2k/si_bulk8.out'),
('parsers/crystal', 'tests/data/parsers/crystal/si.out'),
......
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