From 3eb8aa13621c8c49ba612052764f338c0bf61e3e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 14 Sep 2013 10:52:02 +0000 Subject: [PATCH] checked for python3 compatibility: use "print('foo')" instead of "print 'foo'" and "except(error) as e" instead of "except error,e" --- lib/damask/asciitable.py | 10 +++++----- lib/damask/environment.py | 4 ++-- processing/pre/mentat_spectralBox.py | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/damask/asciitable.py b/lib/damask/asciitable.py index 37dbc581e..2cd94c287 100644 --- a/lib/damask/asciitable.py +++ b/lib/damask/asciitable.py @@ -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 diff --git a/lib/damask/environment.py b/lib/damask/environment.py index bd3674775..3a8c7d039 100644 --- a/lib/damask/environment.py +++ b/lib/damask/environment.py @@ -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 \ No newline at end of file diff --git a/processing/pre/mentat_spectralBox.py b/processing/pre/mentat_spectralBox.py index cb82eb223..e8c3556aa 100755 --- a/processing/pre/mentat_spectralBox.py +++ b/processing/pre/mentat_spectralBox.py @@ -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 = [\