From 99ada57bd0a0bd6c51d880baab15dfd307f684de Mon Sep 17 00:00:00 2001 From: tmadlener Date: Wed, 25 Sep 2024 17:22:53 +0200 Subject: [PATCH] [wip] Fix all print statements --- .../writeAllILDCompactDescriptions.py | 6 +++--- ILD/doc/latex/documentEnvelopes.py | 20 +++++++++---------- ILD/doc/latex/extractParameters.py | 12 +++++------ ILD/scripts/dumpModelParameters.py | 19 +++++++++--------- example/ddsim.py | 14 ++++++------- example/guineapig_to_lcio.py | 2 +- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py b/ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py index 10e6b5dd0..ed170a418 100644 --- a/ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py +++ b/ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py @@ -12,11 +12,11 @@ def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, Anti ecal_sl1=3 ecal_sl2=11 elif Option>1: - print 'ERROR: do not know about Option', Option + print( 'ERROR: do not know about Option', Option) return if FwdFields!=250 and FwdFields!=500 and FwdFields!=1000 and FwdFields!=0: - print 'ERROR: do not know about FwdFields at energy', FwdFields + print( 'ERROR: do not know about FwdFields at energy', FwdFields) return outfile.write('>of, cmd + print(cmd , file=of) of.close() #----------------------------------------------- @@ -353,7 +353,7 @@ def getEnvPoints(det,scale): env = envRZDict[det] for ep in env: p = (scale * values[ ep[0] ], scale * values[ ep[1] ] ) - print det, ' point: ' , p + print( det, ' point: ' , p) points.append( p ) return points @@ -373,7 +373,7 @@ def writeTexFile( det, fileExt, method, width ): cmds.extend( getDocFooterCmds() ) for cmd in cmds: - print >>of, cmd + print(cmd , file=of) of.close() @@ -383,15 +383,15 @@ def lineStr( tl, opt="" ): o = cStringIO.StringIO() - print >>o, '\draw ', opt, + print('\draw ', opt, file=o) i=0 for t in tl: if( i>0 ): - print >>o, ' -- ', - print >>o, '(', t[0] ,',', t[1],') ', + print(' -- ',, file=o) + print('(', t[0] ,',', t[1],') ', file=o) i += 1 - print >>o,';' + print(';', file=o) str = o.getvalue() o.close() return str diff --git a/ILD/doc/latex/extractParameters.py b/ILD/doc/latex/extractParameters.py index 2011dca8c..cc637bb29 100644 --- a/ILD/doc/latex/extractParameters.py +++ b/ILD/doc/latex/extractParameters.py @@ -20,8 +20,8 @@ paramFile = sys.argv[2] dictFile = sys.argv[3] except IndexError: - print " usage: python extractParameters.py compact.xml param_names.txt pyDict.py" - print + print( " usage: python extractParameters.py compact.xml param_names.txt pyDict.py") + print() sys.exit(1) #----------------------------------------------- @@ -40,8 +40,8 @@ def run(): install_dir = os.environ['DD4hepINSTALL'] except (KeyError): - print " please set the environment variable DD4hepINSTALL " - print " to your DD4hep installation path ! " + print( " please set the environment variable DD4hepINSTALL ") + print( " to your DD4hep installation path ! ") exit(1) kernel.loadGeometry("file:"+ compactFile ) @@ -94,9 +94,9 @@ def writeDictionary( names, of ): def printEnvelopeParameters( det ): - print " ========== ", det , " ================== " + print( " ========== ", det , " ================== ") for p in dict[ det ]: - print " ", p , getattr( DDG4, p ) + print( " ", p , getattr( DDG4, p )) #----------------------------------------------- diff --git a/ILD/scripts/dumpModelParameters.py b/ILD/scripts/dumpModelParameters.py index a3ed3f64c..b5e63ff4c 100644 --- a/ILD/scripts/dumpModelParameters.py +++ b/ILD/scripts/dumpModelParameters.py @@ -11,7 +11,7 @@ #--------------------------------------- if len( sys.argv ) != 2: - print " usage: python dumpModelParameters.py MODEL_NAME " + print( " usage: python dumpModelParameters.py MODEL_NAME ") sys.exit(0) model = sys.argv[1] @@ -67,22 +67,21 @@ #dump params to xml file -print >>file, "" +print(" -->", file=file) for k in sorted( params ): v = params[ k ] if v: - print >>file, "" + print("", file=file) else: cur.execute("select name, default_value from parameters where name=\"" + k + "\";") for row in cur.fetchall() : v = row[1] - print >>file, "" - + print("", file=file) diff --git a/example/ddsim.py b/example/ddsim.py index 4cbc64129..0de928c5e 100644 --- a/example/ddsim.py +++ b/example/ddsim.py @@ -17,8 +17,8 @@ try: compactFile = sys.argv[1] except IndexError: - print " usage: python ddsim.py compact.xml" - print + print( " usage: python ddsim.py compact.xml") + print() sys.exit(1) #----------------------------------------------- @@ -95,7 +95,7 @@ def getDetectorLists( lcdd ): type = sd.type() # if len(detectorList) and not(name in detectorList): # continue - print 'getDetectorLists - found active detctor ' , name , ' type: ' , type + print( 'getDetectorLists - found active detctor ' , name , ' type: ' , type) if type == "tracker": t.append( det.name() ) if type == "calorimeter": @@ -113,8 +113,8 @@ def run(): install_dir = os.environ['DD4hepINSTALL'] # lcgeo_dir = os.environ['LCGEO'] except (KeyError): - print " please set the environment variable DD4hepINSTALL " - print " to your DD4hep installation path ! " + print(" please set the environment variable DD4hepINSTALL ") + print( " to your DD4hep installation path ! ") exit(1) # example_dir = lcgeo_dir+'/example'; @@ -210,7 +210,7 @@ def run(): # fixme: this assumes the same filters for all trackers ... for t in trk: - print 'simple.setupTracker( ' , t , ')' + print( 'simple.setupTracker( ' , t , ')') if( 'tpc' in t.lower() ): seq,act = simple.setupTracker( t ,type='TPCSDAction') else: @@ -221,7 +221,7 @@ def run(): # ---- add the calorimeters: for c in cal: - print 'simple.setupCalorimeter( ' , c , ')' + print( 'simple.setupCalorimeter( ' , c , ')') if( 'ecal' in c.lower() ): seq,act = simple.setupCalorimeter( c ,type='CaloPreShowerSDAction') act.FirstLayerNumber = 1 diff --git a/example/guineapig_to_lcio.py b/example/guineapig_to_lcio.py index 7b43e48e3..47e3308b6 100755 --- a/example/guineapig_to_lcio.py +++ b/example/guineapig_to_lcio.py @@ -23,7 +23,7 @@ #================================================ if len( sys.argv ) < 2: - print " usage: python guineapig_to_lcio.py eepair_guineapig.pair " + print(" usage: python guineapig_to_lcio.py eepair_guineapig.pair ") sys.exit(0) #=================================================