Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-gaussian
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-gaussian
Commits
d483892a
Commit
d483892a
authored
9 years ago
by
Mohamed, Fawzi Roberto (fawzi)
Browse files
Options
Downloads
Patches
Plain Diff
adding context, using SM for simple matcher
parent
92dcde8e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-gaussian/parser_gaussian.py
+40
-18
40 additions, 18 deletions
parser/parser-gaussian/parser_gaussian.py
with
40 additions
and
18 deletions
parser/parser-gaussian/parser_gaussian.py
+
40
−
18
View file @
d483892a
import
setup_paths
from
nomadcore.simple_parser
import
SimpleMatcher
,
mainFunction
from
nomadcore.simple_parser
import
mainFunction
,
SimpleMatcher
as
SM
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
import
os
,
sys
,
json
# description of the input
mainFileDescription
=
SimpleMatcher
(
name
=
'
root
'
,
weak
=
True
,
startReStr
=
""
,
subMatchers
=
[
SimpleMatcher
(
name
=
'
newRun
'
,
startReStr
=
r
"
\s*# SampleParser #\s*
"
,
repeats
=
True
,
required
=
True
,
forwardMatch
=
True
,
sections
=
[
'
section_run
'
],
subMatchers
=
[
SimpleMatcher
(
name
=
'
header
'
,
mainFileDescription
=
SM
(
name
=
'
root
'
,
weak
=
True
,
startReStr
=
""
,
subMatchers
=
[
SM
(
name
=
'
newRun
'
,
startReStr
=
r
"
\s*# SampleParser #\s*
"
,
repeats
=
True
,
required
=
True
,
forwardMatch
=
True
,
sections
=
[
'
section_run
'
],
subMatchers
=
[
SM
(
name
=
'
header
'
,
startReStr
=
r
"
\s*# SampleParser #\s*
"
)
])
])
])
])
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/gaussian.nomadmetainfo.json
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"
../../../../nomad-meta-info/meta_info/nomad_meta_info/gaussian.nomadmetainfo.json
"
))
...
...
@@ -29,8 +30,29 @@ parserInfo = {
"
version
"
:
"
1.0
"
}
# default unit conversions (actually it might be better to use the sourceUnits argument of the SimpleMatcher)
defaultSourceUnits
=
{}
class
GaussianParserContext
(
object
):
"""
main place to keep the parser status, open ancillary files,...
"""
def
__init__
(
self
):
self
.
scfIterNr
=
0
# just examples, you probably want to remove the following two triggers
def
onClose_section_single_point_evaluation
(
self
,
backend
,
gIndex
,
section
):
"""
trigger called when section_single_point_evaluation is closed
"""
#backend.addValue("", self.scfIterNr)
logging
.
getLogger
(
"
nomadcore.parsing
"
).
info
(
"
closing section_single_point_evaluation gIndex %d %s
"
,
gIndex
,
section
.
simpleValues
)
self
.
scfIterNr
=
0
def
onClose_section_scf_iteration
(
self
,
backend
,
gIndex
,
section
):
"""
trigger called when section_scf_iteration is closed
"""
logging
.
getLogger
(
"
nomadcore.parsing
"
).
info
(
"
closing section_scf_iteration bla gIndex %d %s
"
,
gIndex
,
section
.
simpleValues
)
self
.
scfIterNr
+=
1
# which values to cache or forward (mapping meta name -> CachingLevel)
cachingLevelForMetaName
=
{}
if
__name__
==
"
__main__
"
:
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
defaultSourceUnits
=
defaultSourceUnits
)
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
superContext
=
GaussianParserContext
(),
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment