Skip to content
GitLab
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-big-dft
Commits
1d8d8e17
Commit
1d8d8e17
authored
Jan 08, 2019
by
Daniel Speckhard
Browse files
Added nomad-fair logging.
parent
b1b03c89
Changes
1
Hide whitespace changes
Inline
Side-by-side
parser/parser-big-dft/bigdftparser/parser.py
View file @
1d8d8e17
# Copyright 2016-2018 Lauri Himanen, 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.
...
...
@@ -17,7 +17,6 @@ import re
import
logging
import
importlib
from
nomadcore.baseclasses
import
ParserInterface
logger
=
logging
.
getLogger
(
"nomad"
)
class
BigDFTParser
(
ParserInterface
):
...
...
@@ -28,8 +27,21 @@ class BigDFTParser(ParserInterface):
After the implementation has been setup, you can parse the files with
parse().
"""
def
__init__
(
self
,
metainfo_to_keep
=
None
,
backend
=
None
,
default_units
=
None
,
metainfo_units
=
None
,
debug
=
True
,
log_level
=
logging
.
ERROR
,
store
=
True
):
super
(
BigDFTParser
,
self
).
__init__
(
metainfo_to_keep
,
backend
,
default_units
,
metainfo_units
,
debug
,
log_level
,
store
)
def
__init__
(
self
,
metainfo_to_keep
=
None
,
backend
=
None
,
default_units
=
None
,
metainfo_units
=
None
,
debug
=
True
,
logger
=
None
,
log_level
=
logging
.
ERROR
,
store
=
True
):
super
(
BigDFTParser
,
self
).
__init__
(
metainfo_to_keep
,
backend
,
default_units
,
metainfo_units
,
debug
,
log_level
,
store
)
if
logger
is
not
None
:
self
.
logger
=
logger
self
.
logger
.
debug
(
'received logger'
)
else
:
self
.
logger
=
logging
.
getLogger
(
__name__
)
def
setup_version
(
self
):
"""Setups the version by looking at the output file and the version
...
...
@@ -50,7 +62,7 @@ class BigDFTParser(ParserInterface):
if
version_id
is
None
:
msg
=
"Could not find a version specification from the given main file."
logger
.
exception
(
msg
)
self
.
logger
.
exception
(
msg
)
raise
RuntimeError
(
msg
)
# Setup the root folder to the fileservice that is used to access files
...
...
@@ -78,17 +90,17 @@ class BigDFTParser(ParserInterface):
try
:
parser_module
=
importlib
.
import_module
(
base
)
except
ImportError
:
logger
.
warning
(
"Could not find a parser for version '{}'. Trying to default to the base implementation for BigDFT 1.8.0"
.
format
(
version_id
))
self
.
logger
.
warning
(
"Could not find a parser for version '{}'. Trying to default to the base implementation for BigDFT 1.8.0"
.
format
(
version_id
))
base
=
"bigdftparser.versions.bigdft18.mainparser"
try
:
parser_module
=
importlib
.
import_module
(
base
)
except
ImportError
:
logger
.
exception
(
"Could not find the module '{}'"
.
format
(
base
))
self
.
logger
.
exception
(
"Could not find the module '{}'"
.
format
(
base
))
raise
try
:
class_name
=
"BigDFTMainParser"
parser_class
=
getattr
(
parser_module
,
class_name
)
except
AttributeError
:
logger
.
exception
(
"A parser class '{}' could not be found in the module '[]'."
.
format
(
class_name
,
parser_module
))
self
.
logger
.
exception
(
"A parser class '{}' could not be found in the module '[]'."
.
format
(
class_name
,
parser_module
))
raise
self
.
main_parser
=
parser_class
(
self
.
parser_context
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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