From 2ee431d51898153552e08086651befdc585a4c2b Mon Sep 17 00:00:00 2001 From: Jaime RGP Date: Mon, 29 Jan 2018 11:06:59 +0100 Subject: [PATCH] Make sure {{route}} is only parsed once. Document it. --- docs/templates.md | 1 + esigen/io.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/templates.md b/docs/templates.md index 01f412c..32d255c 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -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. diff --git a/esigen/io.py b/esigen/io.py index e6f5ff8..9bf2cf0 100644 --- a/esigen/io.py +++ b/esigen/io.py @@ -128,6 +128,7 @@ def pdb_block(self): pdb.append('ENDMDL\nEND\n') return '\n'.join(pdb) + class GaussianParser(_cclib_Gaussian): """ @@ -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: