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-wien2k
Commits
16f7a7f6
Commit
16f7a7f6
authored
Mar 20, 2020
by
Markus Scheidgen
Browse files
Parser optimizations.
parent
2ef508e9
Changes
8
Show whitespace changes
Inline
Side-by-side
wien2kparser/parser_wien2k.py
View file @
16f7a7f6
...
...
@@ -13,9 +13,9 @@ import wien2kparser.wien2k_parser_in1c as wien2k_parser_in1c
import
wien2kparser.wien2k_parser_in2c
as
wien2k_parser_in2c
import
wien2kparser.wien2k_parser_in1
as
wien2k_parser_in1
import
wien2kparser.wien2k_parser_in2
as
wien2k_parser_in2
import
wien2kparser.setup_paths
as
setup_paths
import
logging
as
_logging
from
nomad.parsing.legacy
import
CoESimpleMatcherParser
################################################################
# This is the parser for the main output file (.scf) of WIEN2k.
...
...
@@ -266,47 +266,26 @@ mainFileDescription = SM(
])
# which values to cache or forward (mapping meta name -> CachingLevel)
class
Wien2kParser
(
CoESimpleMatcherParser
):
cachingLevelForMetaName
=
{
def
metainfo_env
(
self
):
from
.metainfo
import
m_env
return
m_env
"XC_functional_name"
:
CachingLevel
.
ForwardAndCache
,
"energy_total"
:
CachingLevel
.
ForwardAndCache
def
create_super_context
(
self
):
return
Wien2kContext
()
}
def
create_simple_matcher
(
self
):
return
mainFileDescription
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
parserInfo
=
{
def
create_parser_description
(
self
):
return
{
"name"
:
"Wien2k"
,
"version"
:
"1.0"
}
class
Wien2kParser
():
""" A proper class envolop for running this parser from within python. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
from
unittest.mock
import
patch
_logging
.
getLogger
(
'nomadcore'
).
setLevel
(
_logging
.
WARNING
)
backend
=
self
.
backend_factory
(
"wien2k.nomadmetainfo.json"
)
with
patch
.
object
(
sys
,
'argv'
,
[
'<exe>'
,
'--uri'
,
'nmd://uri'
,
mainfile
]):
mainFunction
(
mainFileDescription
,
None
,
parserInfo
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
superContext
=
Wien2kContext
(),
superBackend
=
backend
)
return
backend
if
__name__
==
"__main__"
:
import
metainfo
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
metainfo
.
__file__
)),
"wien2k.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
superContext
=
Wien2kContext
()
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
superContext
=
superContext
)
}
def
create_caching_levels
(
self
):
return
{
"XC_functional_name"
:
CachingLevel
.
ForwardAndCache
,
"energy_total"
:
CachingLevel
.
ForwardAndCache
}
wien2kparser/setup_paths.py
deleted
100644 → 0
View file @
2ef508e9
# Copyright 2016-2018 Daria Tomecka, Fawzi Mohamed
#
# 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
,
os
,
os
.
path
baseDir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
commonDir
=
os
.
path
.
normpath
(
os
.
path
.
join
(
baseDir
,
"../../../../python-common/common/python"
))
if
not
commonDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
commonDir
)
wien2kparser/wien2k_parser_in0.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
wien2kparser/wien2k_parser_in1.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
wien2kparser/wien2k_parser_in1c.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
wien2kparser/wien2k_parser_in2.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
wien2kparser/wien2k_parser_in2c.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
wien2kparser/wien2k_parser_struct.py
View file @
16f7a7f6
from
builtins
import
object
import
wien2kparser.setup_paths
as
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment