Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-siesta
Commits
b16155f7
Commit
b16155f7
authored
Jul 07, 2016
by
Ask Hjorth Larsen
Browse files
fix array lengths when same thing is parsed multiple times
parent
c39af793
Changes
1
Show whitespace changes
Inline
Side-by-side
parser/parser-siesta/parser.py
View file @
b16155f7
...
...
@@ -29,16 +29,20 @@ def siesta_energy(title, meta, **kwargs):
def
ArraySM
(
header
,
row
,
build
,
**
kwargs
):
lines
=
[]
def
addrow
(
parser
)
:
line
=
parser
.
fIn
.
readline
()
lines
.
append
(
line
)
class
LineBuf
:
def
__init__
(
self
):
self
.
lines
=
[]
def
_build_array
(
parser
):
build
(
parser
.
backend
.
superBackend
,
lines
)
def
addrow
(
self
,
parser
):
line
=
parser
.
fIn
.
readline
()
self
.
lines
.
append
(
line
)
def
_build_array
(
self
,
parser
):
build
(
parser
.
backend
.
superBackend
,
self
.
lines
)
self
.
lines
=
[]
linebuf
=
LineBuf
()
sm
=
SM
(
header
,
name
=
kwargs
.
pop
(
'name'
,
'startarray'
),
required
=
True
,
...
...
@@ -46,8 +50,8 @@ def ArraySM(header, row, build, **kwargs):
subMatchers
=
[
SM
(
row
,
name
=
'array'
,
repeats
=
True
,
forwardMatch
=
True
,
adHoc
=
addrow
,
required
=
True
),
SM
(
r
''
,
endReStr
=
''
,
adHoc
=
_build_array
,
name
=
'endarray'
,
adHoc
=
linebuf
.
addrow
,
required
=
True
),
SM
(
r
''
,
endReStr
=
''
,
adHoc
=
linebuf
.
_build_array
,
name
=
'endarray'
,
forwardMatch
=
True
)
],
**
kwargs
)
...
...
@@ -184,6 +188,13 @@ infoFileDescription = SM(
r
'\s*[0-9]+\s+\S+\s+\S+\s+\S+'
,
get_forces
,
name
=
'forces-in-opt-step'
),
SM
(
r
'Target enthalpy'
,
name
=
'end-singleconfig'
),
# As we get past the last singleconfig, we need to add all the stuff
# that pertains only to the last one, basically eigs and occs.
# Therefore we read a bit past the last config and try to trigger
# this as appropriate.
#SM(r'outcoor: Relaxed atomic coordinates',
# adHoc=read_eigenvalues),
#])
SM
(
r
''
,
weak
=
True
,
name
=
'After singleconfigs'
,
subFlags
=
SM
.
SubFlags
.
Sequenced
,
subMatchers
=
[
...
...
@@ -222,7 +233,7 @@ infoFileDescription = SM(
# The purpose of the following matcher is to parse all lines
SM
(
r
'x^'
,
name
=
'end'
)
])
])
,
])
])
class
SiestaContext
(
object
):
...
...
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