Skip to content

Commit

Permalink
Fix regressions of python 2 modernization features
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvaandering committed Feb 22, 2016
1 parent ba4b706 commit 11b8252
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions DQMServices/Components/scripts/dqm-mbProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def get_children(ppid):
for pid in list(pid_dct.keys()):
parent_pid = pid_dct[pid]["parent_pid"]

if pid_dct.has_key(parent_pid):
if parent_pid in pid_dct:
pid_dct[parent_pid]["_children"].append(pid)

# now just walk down the tree
if ppid is None or not pid_dct.has_key(ppid):
if ppid is None or ppid not in pid_dct:
# process has quit, we exit
return []

Expand Down
6 changes: 3 additions & 3 deletions Documentation/ReferenceManualScripts/python/TableParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def extractPages(configFileFlag = False):
# parents. This is why we need to check whether row has a style
# attribute or not.
styleFlag = False
if row.has_key('style'): styleFlag = True
if 'style' in row: styleFlag = True
# change the first letter if row is not hidden (child) one
if not styleFlag: firstLetter = row.findAll('td')[0].text[0].upper()
# if pages dict doesn't have the page yet..
if not pages.has_key(firstLetter):
if firstLetter not in pages:
pages[firstLetter] = []
# insert the row into the related page
if configFileFlag:
Expand All @@ -55,7 +55,7 @@ def extractPagesForPackage():
# parse package names --please have a look at the pages.html file
name = name[name.find(' '):name.find('/')].strip()
# if the package is not added yet
if not pages.has_key(name): pages[name] = []
if name not in pages: pages[name] = []
pages[name].append(row)
return pages

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1TGlobal/test/runGlobalFakeInputProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

process.output =cms.OutputModule("PoolOutputModule",
outputCommands = cms.untracked.vstring('keep *'),
fileName = cms.untracked.string('testGlobalMCInputProducer_'+`job`+'.root')
fileName = cms.untracked.string('testGlobalMCInputProducer_'+repr(job)+'.root')
)

process.options = cms.untracked.PSet()
Expand Down Expand Up @@ -258,6 +258,6 @@
#process.options.numberOfStreams = cms.untracked.uint32( 0 )

if dump:
outfile = open('dump_runGlobalFakeInputProducer_'+`job`+'.py','w')
outfile = open('dump_runGlobalFakeInputProducer_'+repr(job)+'.py','w')
print >> outfile,process.dumpPython()
outfile.close()
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
# Additional output definition
# TTree output file
process.load("CommonTools.UtilAlgos.TFileService_cfi")
process.TFileService.fileName = cms.string('l1tCalo_2016_histos_'+`options.gtOffset`+'-'+`options.gtLatency`+'.root')
process.TFileService.fileName = cms.string('l1tCalo_2016_histos_'+repr(options.gtOffset)+'-'+repr(options.gtLatency)+'.root')


# enable debug message logging for our modules
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1TNtuples/python/customiseL1Ntuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def L1NtupleRAW(process):
process.schedule.append(process.l1ntupleraw)

# for 5 BX of candidates in L1Extra
if process.producers.has_key("gctDigis"):
if "gctDigis" in process.producers:
process.gctDigis.numberOfGctSamplesToUnpack = cms.uint32(5)

if process.producers.has_key("l1extraParticles"):
if "l1extraParticles" in process.producers:
process.l1extraParticles.centralBxOnly = cms.bool(False)

return process
Expand Down
10 changes: 5 additions & 5 deletions Validation/Tools/scripts/edmOneToOneComparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
if lenArgs == 3:
options.file2 = args[2]
if lenArgs > 3:
raise RuntimeError, "Too many arguments"
raise RuntimeError("Too many arguments")

# Here we go
random.seed( os.getpid() )
Expand All @@ -124,7 +124,7 @@
aliasMatch.group (3))
continue
# if we're here, then we have an argument that we don't understand
raise RuntimeError, "Unknown alias format '%s'" % arg
raise RuntimeError("Unknown alias format '%s'" % arg)
tripleColonRE = re.compile (r'(.+):(.+):(.+):(.+)')
if options.changeVar:
for arg in options.changeVar:
Expand All @@ -136,13 +136,13 @@
changeMatch.group (4))
continue
# if we're here, then we have an argument that we don't understand
raise RuntimeError, "Unknown changeVar format '%s'" % arg
raise RuntimeError("Unknown changeVar format '%s'" % arg)
if options.label:
for label in options.label:
pieces = label.split('^')
if len (pieces) != 3:
raise RuntimeError, "Can't process label command '%s'" \
% options.label
raise RuntimeError("Can't process label command '%s'" \
% options.label)
GenObject.changeLabel (*pieces)
# We don't want to use options beyond the main code, so let the
# kitchen sink know what we want
Expand Down
6 changes: 3 additions & 3 deletions Validation/Tools/scripts/useReflexToDescribeForGenObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def genObjectDef (mylist, tuple, alias, label, type, etaPhiFound):
firstName = mylist[0][0]
match = alphaRE.match (firstName)
if not match:
raise RuntimeError, "firstName doesn't parse correctly. (%s)" \
% firstName
raise RuntimeError("firstName doesn't parse correctly. (%s)" \
% firstName)
genName = match.group (1)
genDef = " ## GenObject %s Definition ##\n[%s]\n" % \
(genName, genName)
Expand Down Expand Up @@ -221,7 +221,7 @@ def genObjectDef (mylist, tuple, alias, label, type, etaPhiFound):
from Validation.Tools.GenObject import GenObject
options.type = GenObject.decodeNonAlphanumerics (options.type)
if len (args) < 1:
raise RuntimeError, "Need to provide object name."
raise RuntimeError("Need to provide object name.")
#
objectName = GenObject.decodeNonAlphanumerics (args[0])
goName = options.goName or colonRE.sub ('', objectName)
Expand Down

0 comments on commit 11b8252

Please sign in to comment.