PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/ase/thermochemistry/thermochemistry.py

https://gitlab.com/vote539/ase
Python | 31 lines | 21 code | 5 blank | 5 comment | 5 complexity | 5118901e796efbefd5642bd827c80582 MD5 | raw file
 1# creates:  nitrogen.txt
 2import os
 3import sys
 4from StringIO import StringIO
 5
 6def output_to_string(pythonfile):
 7    """Returns the stdout of executing the code in pythonfile
 8    as a string."""
 9    buffer = StringIO()
10    sys.stdout = buffer
11    execfile(pythonfile)
12    sys.stdout = sys.__stdout__
13    return buffer.getvalue()
14
15# Only save the parts relevant to thermochemistry
16nitrogen = output_to_string('nitrogen.py')
17nitrogen = nitrogen[nitrogen.find('Enthalpy'):]
18with open('nitrogen.txt', 'w') as f:
19    f.write(nitrogen)
20gold = output_to_string('gold.py')
21gold = gold[gold.find('Internal'):]
22with open('gold.txt', 'w') as f:
23    f.write(gold)
24
25# Clean up.
26vibfiles = [file for file in os.listdir(os.getcwd()) if
27            file.startswith('vib.') or file.startswith('phonon.')]
28for file in vibfiles:
29    os.remove(file)
30
31