Skip to content

Commit

Permalink
Make sure {{route}} is only parsed once. Document it.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Jan 29, 2018
1 parent 55923fd commit 2ee431d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Additionally, ESIgen provides some more fields and methods you can use during th
- `{{ stoichiometry }}`.
- `{{ imaginary_freqs }}`: Number of negative frequencies.
- `{{ mean_of_electrons }}`: Mean of `alphaelectrons` and `betaelectrons`.
- `{{ route }}`: First of Gaussian route sections. For other programs, check `metadata`.
- Magnitudes
- `{{ electronic_energy }}`. Last of `scfenergies`, Eh.
- `{{ thermalenergy }}`: Sum of electronic and thermal energies, Eh.
Expand Down
7 changes: 4 additions & 3 deletions esigen/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def pdb_block(self):
pdb.append('ENDMDL\nEND\n')
return '\n'.join(pdb)


class GaussianParser(_cclib_Gaussian):

"""
Expand Down Expand Up @@ -155,11 +156,11 @@ def extract(self, inputfile, line):
beta_index = fields.index('beta')
self.set_attribute('alphaelectrons', int(fields[alpha_index-1]))
self.set_attribute('betaelectrons', int(fields[beta_index-1]))
if line.strip().startswith('#'):
route_lines = [line.strip().split('#', 1)[1]]
if line.strip().startswith('#') and not hasattr(self, 'route'):
route_lines = line.strip().split('#', 1)[1:2]
line = inputfile.next()
while '-----' not in line:
route_lines.append(line.lstrip())
route_lines.append(line[1:].rstrip())
line = inputfile.next()
self.set_attribute('route', ''.join(route_lines).strip())
except Exception as e:
Expand Down

0 comments on commit 2ee431d

Please sign in to comment.