Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add python formatting to pre-commit and make all files comply #398

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix all python2 print statements
tmadlener committed Sep 26, 2024
commit af1ab40bfa20fe16176177596e8482fdc9ef59c6
6 changes: 3 additions & 3 deletions ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py
Original file line number Diff line number Diff line change
@@ -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('<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"\n')
@@ -151,7 +151,7 @@ def getVersionParameters(version):
vparams['AntiDID']=True
vparams['FwdFields']=1000
else:
print 'ERROR: unknown version requested:',version,'!!'
print( 'ERROR: unknown version requested:',version,'!!')
return vparams

if version<10:
20 changes: 10 additions & 10 deletions ILD/doc/latex/documentEnvelopes.py
Original file line number Diff line number Diff line change
@@ -190,9 +190,9 @@
dictFile = sys.argv[1]

except IndexError:
print " usage: python documentEnvelopes.py pyDict.py "
print " pyDict.py : python file with a data dictionary (created with extractParameters)"
print
print( " usage: python documentEnvelopes.py pyDict.py ")
print( " pyDict.py : python file with a data dictionary (created with extractParameters)")
print()
sys.exit(1)


@@ -230,7 +230,7 @@ def writeILDEnvTable( file ):
cmds.extend( getDocFooterCmds() )

for cmd in cmds:
print >>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
12 changes: 6 additions & 6 deletions ILD/doc/latex/extractParameters.py
Original file line number Diff line number Diff line change
@@ -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 ))


#-----------------------------------------------
19 changes: 9 additions & 10 deletions ILD/scripts/dumpModelParameters.py
Original file line number Diff line number Diff line change
@@ -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, " global model parameters for model: " + model
print >>file, " extracted from Mokka DB at " + host + " - db: " + dbName
print >>file, " on " + time.strftime("%d/%m/%Y")
print >>file, " at " + time.strftime("%H:%M:%S")
print("<!-- ", file=file)
print(" global model parameters for model: " + model, file=file)
print(" extracted from Mokka DB at " + host + " - db: " + dbName , file=file)
print(" on " + time.strftime("%d/%m/%Y"), file=file)
print(" at " + time.strftime("%H:%M:%S"), file=file)

print >>file, " -->"
print(" -->", file=file)


for k in sorted( params ):
v = params[ k ]
if v:
print >>file, "<constant name=\"" + k + "\" value=\"" + str(v) + "\"/>"
print("<constant name=\"" + k + "\" value=\"" + str(v) + "\"/>", file=file)
else:
cur.execute("select name, default_value from parameters where name=\"" + k + "\";")
for row in cur.fetchall() :
v = row[1]
print >>file, "<constant name=\"" + k + "\" value=\"" + str(v) + "\"/>"

print("<constant name=\"" + k + "\" value=\"" + str(v) + "\"/>", file=file)
2 changes: 1 addition & 1 deletion example/guineapig_to_lcio.py
Original file line number Diff line number Diff line change
@@ -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)

#=================================================