[cig-commits] [commit] master: py: Make config parsing work on Py3k. (04f0785)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Sat Jan 17 08:39:54 PST 2015
Repository : https://github.com/geodynamics/specfem1d
On branch : master
Link : https://github.com/geodynamics/specfem1d/compare/58c6e68e5fc4e335b2fa135ce471179cc1f417fc...d71011cecc0efd4599edda577831565bbebd41ac
>---------------------------------------------------------------
commit 04f07853e6c14a276e0d5d75a4090a911d3b9566
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date: Fri Jan 16 21:18:59 2015 -0500
py: Make config parsing work on Py3k.
>---------------------------------------------------------------
04f07853e6c14a276e0d5d75a4090a911d3b9566
Python_version/config.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Python_version/config.py b/Python_version/config.py
index 9f682d0..03d1984 100644
--- a/Python_version/config.py
+++ b/Python_version/config.py
@@ -89,7 +89,12 @@ class Parameter(object):
'DPLOT': 10,
})
with open('Par_file') as f:
- cp.readfp(FakeGlobalSectionHead(f))
+ try:
+ # Python 3
+ cp.read_string('[global]\n' + f.read(), source='Par_file')
+ except AttributeError:
+ # Python 2
+ cp.readfp(FakeGlobalSectionHead(f))
self.axisym = cp.getboolean('global', 'AXISYM')
self.length = cp.getfloat('global', 'LENGTH')
More information about the CIG-COMMITS
mailing list