checked for python3 compatibility:

use "print('foo')" instead of "print 'foo'"
and "except(error) as e" instead of "except error,e"
This commit is contained in:
Martin Diehl 2013-09-14 10:52:02 +00:00
parent 5f973a21c0
commit 3eb8aa1362
3 changed files with 12 additions and 12 deletions

View File

@ -52,7 +52,7 @@ class ASCIItable():
import sys
try:
self.__IO__['output'] == [] or self.__IO__['out'].write('\n'.join(self.__IO__['output']) + '\n')
except IOError, e:
except(IOError) as e:
return False
if clear: self.output_clear()
return True
@ -89,7 +89,7 @@ class ASCIItable():
# ... without any labels
try:
self.__IO__['dataStart'] = self.__IO__['in'].tell() # current file position is at start of data
except IOError:
except(IOError):
pass
if self.__IO__['validReadSize'] == 0: # in case no valid data length is known
@ -137,12 +137,12 @@ class ASCIItable():
for label in labels:
try:
idx.append(self.labels.index(label))
except ValueError:
except(ValueError):
idx.append(-1)
else:
try:
idx = self.labels.index(labels)
except ValueError:
except(ValueError):
idx = -1
return idx
@ -221,7 +221,7 @@ class ASCIItable():
if len(self.data) <= idx:
self.data_append(['n/a' for i in xrange(idx+1-len(self.data))]) # grow data if too short
self.data[idx] = str(what)
except ValueError:
except(ValueError):
pass
return idx

View File

@ -62,8 +62,8 @@ class Environment():
if licenses[0]-licenses[1] >= noNeeded:
return 0
else:
print licenses[1] + noNeeded - licenses[0], 'missing licenses for %s'%software
print(licenses[1] + noNeeded - licenses[0], 'missing licenses for %s'%software)
return licenses[1] + noNeeded - licenses[0]
except IndexError:
print 'Could not retrieve license information for %s'%software
print('Could not retrieve license information for %s'%software)
return 127

View File

@ -26,9 +26,9 @@ def outStdout(cmd,locals):
exec(cmd[3:])
elif cmd[0:3] == '(?)':
cmd = eval(cmd[3:])
print cmd
print(cmd)
else:
print cmd
print(cmd)
return
#-------------------------------------------------------------------------------------------------
@ -271,11 +271,11 @@ file = open(args[0])
content = file.readlines()
file.close()
print '\033[1m'+scriptName+'\033[0m\n'
print('\033[1m'+scriptName+'\033[0m\n')
if options.filetype not in ['spectral','geom']:
options.filetype = os.path.splitext(args[0])[1][1:]
print '\nparsing %s...'%options.filetype,
print('\nparsing %s...'%options.filetype,)
sys.stdout.flush()
(grid,size,homog,microstructures) = {\
@ -283,7 +283,7 @@ sys.stdout.flush()
'spectral': parse_spectralFile,
}[options.filetype](content,options.homogenization)
print '%i microstructures in %s with grid %s and homogenization %i\n'%(len(list(set(microstructures))),str(size),str(grid),homog)
print('%i microstructures in %s with grid %s and homogenization %i\n'%(len(list(set(microstructures))),str(size),str(grid),homog))
cmds = [\