10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-23 04:43:50 +01:00

PEP 8 in ezfio_with_default and typo

This commit is contained in:
Thomas Applencourt 2015-03-26 12:52:07 +01:00
parent 246cc66936
commit 22bae15794

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
__author__ = "Anthony Scemama"
__date__ = "Tue Jul 29 12:20:00 CEST 2014"
__author__ = "Anthony Scemama and Applencourt for the amazing PEP8"
__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)"
"""
Creates the provider of a variable that has to be
@ -33,8 +33,7 @@ class EZFIO_Provider(object):
END_PROVIDER
"""
write_correspondance = {
"integer" : "write_int",
write_correspondance = {"integer": "write_int",
"logical": "write_bool",
"double precision": "write_double"}
@ -49,7 +48,8 @@ END_PROVIDER
for v in self.values:
exec "test = self.%s is None" % (v) in locals()
if test:
print >>sys.stderr, "Error : %s is not set in ezfio_with_default.py"%(v)
msg = "Error : %s is not set in ezfio_with_default.py" % (v)
print >>sys.stderr, msg
for v in self.values:
exec "x = str(self.%s)" % (v) in locals()
print >>sys.stderr, "%s : %s" % (v, x)
@ -65,8 +65,7 @@ END_PROVIDER
self.write = """
call write_time(%(output)s)
call %(write)s(%(output)s, %(name)s, &
'%(name)s')
"""%locals()
'%(name)s')""" % locals()
def set_type(self, t):
self.type = t.lower()
@ -90,10 +89,13 @@ END_PROVIDER
self.default = t
def get_default(self):
filename = '/'.join( [os.environ['QPACKAGE_ROOT'], 'data', 'ezfio_defaults'] )
file = open(filename,'r')
lines = file.readlines()
file.close()
filename = '/'.join([os.environ['QPACKAGE_ROOT'],
'data',
'ezfio_defaults'])
with open(filename, 'r') as f:
lines = f.readlines()
# Search directory
for k, line in enumerate(lines):
if line[0] != ' ':
@ -113,9 +115,9 @@ END_PROVIDER
name = self.name
try:
v_eval = eval(v)
if type(v_eval) == bool:
if isinstance(v_eval, bool):
v = '.%s.' % (v)
elif type(v_eval) == float:
elif isinstance(v_eval, float):
v = v.replace('e', 'd')
v = v.replace('E', 'D')
v = "%(name)s = %(v)s" % locals()
@ -137,5 +139,3 @@ def test_module():
if __name__ == '__main__':
test_module()