Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-vasp
Compare Revisions
2c8b7763eae8a27e7c1ca3a8ce86533978f42f73...8c2e56b0d9d17b777b5fa6a61c8e2877444ab603
Commits (1)
Switched to FairdiParser with archive not backend.
· 8c2e56b0
Markus Scheidgen
authored
Jul 30, 2020
8c2e56b0
Hide whitespace changes
Inline
Side-by-side
vaspparser/__init__.py
View file @
8c2e56b0
...
@@ -18,13 +18,15 @@ import gzip
...
@@ -18,13 +18,15 @@ import gzip
import
bz2
import
bz2
import
lzma
import
lzma
from
nomad.datamodel
import
EntryArchive
from
.metainfo
import
m_env
from
.metainfo
import
m_env
from
vaspparser.parser_vasprun
import
VasprunContext
,
XmlParser
,
parser_info
from
vaspparser.parser_vasprun
import
VasprunContext
,
XmlParser
,
parser_info
from
nomad.parsing.parser
import
Matching
Parser
from
nomad.parsing.parser
import
Fairdi
Parser
from
vaspparser.parser_outcar
import
VaspOutcarParser
from
vaspparser.parser_outcar
import
VaspOutcarParser
class
VASPParser
(
Matching
Parser
):
class
VASPParser
(
Fairdi
Parser
):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
(
super
().
__init__
(
name
=
'parsers/vasp'
,
code_name
=
'VASP'
,
code_homepage
=
'https://www.vasp.at/'
,
name
=
'parsers/vasp'
,
code_name
=
'VASP'
,
code_homepage
=
'https://www.vasp.at/'
,
...
@@ -38,7 +40,7 @@ class VASPParser(MatchingParser):
...
@@ -38,7 +40,7 @@ class VASPParser(MatchingParser):
supported_compressions
=
[
'gz'
,
'bz2'
,
'xz'
]
supported_compressions
=
[
'gz'
,
'bz2'
,
'xz'
]
)
)
def
run
(
self
,
filepath
,
logger
=
None
):
def
parse
(
self
,
filepath
,
archive
,
logger
=
None
):
self
.
_metainfo_env
=
m_env
self
.
_metainfo_env
=
m_env
super_context
=
VasprunContext
(
logger
=
logger
)
super_context
=
VasprunContext
(
logger
=
logger
)
...
@@ -53,5 +55,4 @@ class VASPParser(MatchingParser):
...
@@ -53,5 +55,4 @@ class VASPParser(MatchingParser):
elif
filepath
.
endswith
(
'.xz'
):
elif
filepath
.
endswith
(
'.xz'
):
open_file
=
lzma
.
open
open_file
=
lzma
.
open
parser
.
parse
(
os
.
path
.
abspath
(
filepath
),
open_file
(
filepath
,
'rt'
))
parser
.
parse
(
os
.
path
.
abspath
(
filepath
),
open_file
(
filepath
,
'rt'
),
archive
)
return
parser
.
root_section
vaspparser/__main__.py
0 → 100644
View file @
8c2e56b0
# 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
vaspparser/parser_vasprun.py
View file @
8c2e56b0
...
@@ -954,13 +954,13 @@ class XmlParser(object):
...
@@ -954,13 +954,13 @@ class XmlParser(object):
self
.
tagSections
=
{}
self
.
tagSections
=
{}
self
.
metainfo_env
=
metainfo_env
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
:
if
self
.
path
:
raise
Exception
(
raise
Exception
(
"Parse of %s called with non empty path, parse already in progress?"
%
main_file_uri
)
"Parse of %s called with non empty path, parse already in progress?"
%
main_file_uri
)
self
.
main_file_uri
=
main_file_uri
self
.
main_file_uri
=
main_file_uri
self
.
f_in
=
f_in
self
.
f_in
=
f_in
self
.
root_section
=
msection_run
(
)
self
.
root_section
=
archive
.
m_create
(
msection_run
)
self
.
super_context
.
parser
=
self
self
.
super_context
.
parser
=
self
# there are invalid characters like esc in the files, we do not want to crash on them
# there are invalid characters like esc in the files, we do not want to crash on them
xml_parser
=
MyXMLParser
()
xml_parser
=
MyXMLParser
()
...
...