Skip to content

Commit

Permalink
Merge pull request #46096 from smuzaffar/analysis-py312-SyntaxWarning
Browse files Browse the repository at this point in the history
[ANALYSIS] [PY312] String formatting to fix SyntaxWarning
  • Loading branch information
cmsbuild authored Sep 24, 2024
2 parents dc4848f + d4d8ac9 commit f44543a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions PhysicsTools/Heppy/python/utils/cmsswRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ def releaseNumber(release = None):
# first check if this is an integration build
if release is None:
release = cmsswRelease()
ibrel = re.compile('^CMSSW_(\d+)_(\d+)_X.*$')
ibrel = re.compile('^CMSSW_(\\d+)_(\\d+)_X.*$')
m = ibrel.match(release)
if m:
big = int(m.group(1))
medium = int(m.group(2))
return big, medium
rerel = re.compile('^CMSSW_(\d+)_(\d+)_(\d+)(_\S+)*$')
rerel = re.compile('^CMSSW_(\\d+)_(\\d+)_(\\d+)(_\\S+)*$')
m = rerel.match(release)
if m is None:
raise ValueError('malformed release string '+release)
big = int(m.group(1))
medium = int(m.group(2))
small = int(m.group(3))
if m.group(4): # that's either a patch or prerelease
prel = re.compile('_pre(\d+)')
patch = re.compile('_patch(\d+)')
prel = re.compile('_pre(\\d+)')
patch = re.compile('_patch(\\d+)')
pm = prel.match(m.group(4))
if pm: # prerelease
pre = int(pm.group(1))
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/HeppyCore/python/framework/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __str__(self):
name=self.name)
varlines = ['\t{var:<15}: {value}'.format(var=var, value=value) \
for var,value in sorted(vars(self.items())) \
if var is not 'name']
if var != 'name']
all = [ header ]
all.extend(varlines)
return '\n'.join( all )
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/HeppyCore/python/utils/batchmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def CheckBatchScript( self, batchScript ):
sys.exit(3)
else:
for line in ifile:
p = re.compile("\s*cp.*\$jobdir\s+(\S+)$");
p = re.compile("\\s*cp.*\\$jobdir\\s+(\\S+)$");
m=p.match(line)
if m:
if os.path.isdir( os.path.expandvars(m.group(1)) ):
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/HeppyCore/python/utils/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def buildListOfBadFiles(self):
self.bad_files = {}
self.good_files = []

file_mask = castortools.matchingFiles(self.castorDir, '^%s_.*\.txt$' % mask)
file_mask = castortools.matchingFiles(self.castorDir, '^%s_.*\\.txt$' % mask)
if file_mask:
# here to avoid circular dependency
from .edmIntegrityCheck import PublishToFileSystem
Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/HeppyCore/python/utils/edmIntegrityCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def read(self, lfn, local = False):

def get(self, dir):
"""Finds the lastest file and reads it"""
reg = '^%s_.*\.txt$' % self.parent
reg = '^%s_.*\\.txt$' % self.parent
files = castortools.matchingFiles(dir, reg)
files = sorted([ (os.path.basename(f), f) for f in files])
if not files:
Expand Down Expand Up @@ -117,7 +117,7 @@ def stripDuplicates(self):
def isCrabFile(name):
_, fname = os.path.split(name)
base, _ = os.path.splitext(fname)
return re.match(".*_\d+_\d+_\w+$", base) is not None, base
return re.match(".*_\\d+_\\d+_\\w+$", base) is not None, base
def getCrabIndex(base):
tokens = base.split('_')
if len(tokens) > 2:
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/HeppyCore/python/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def isTgzDirOnEOS(self, file ):
file = castortools.castorToLFN(file)

if castortools.isLFN( file ):
tgzPattern = re.compile('.*\.tgz$')
tgzPattern = re.compile('.*\\.tgz$')
m = tgzPattern.match( file )
if m:
return True
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/HeppyCore/python/utils/production_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def run(self, input):

report = None
if (hasattr(self.options,'check') and self.options.check) or not hasattr(self.options,'check'):
file_mask = castortools.matchingFiles(dir, '^%s_.*\.txt$' % mask)
file_mask = castortools.matchingFiles(dir, '^%s_.*\\.txt$' % mask)

if file_mask:
p = PublishToFileSystem(mask)
Expand Down

0 comments on commit f44543a

Please sign in to comment.