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