Commit b16155f7 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen
Browse files

fix array lengths when same thing is parsed multiple times

parent c39af793
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment