Skip to content

Commit 8e63634

Browse files
committed
Raw-string update
1 parent 1b6d18c commit 8e63634

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/Python/mctest/mctest.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_processor_info():
2626
elif platform.system() == "Darwin":
2727
return subprocess.check_output(['/usr/sbin/sysctl', "-n", "machdep.cpu.brand_string"]).strip().decode('utf-8')
2828
elif platform.system() == "Linux":
29-
command = "cat /proc/cpuinfo | grep model\ name | uniq | cut -f2 -d:"
29+
command = r"cat /proc/cpuinfo | grep model\ name | uniq | cut -f2 -d:"
3030
return subprocess.check_output(command, shell=True).strip().decode('utf-8')
3131

3232
return ""
@@ -38,7 +38,7 @@ def get_processor_info():
3838
def create_instr_test_objs(sourcefile, localfile, header):
3939
''' returns a list containing one initialized test object pr %Example within the instr file '''
4040
tests = []
41-
ms = re.findall("\%Example:([^\n]*)Detector\:([^\n]*)_I=([0-9.+-e]+)", header)
41+
ms = re.findall(r"\%Example:([^\n]*)Detector\:([^\n]*)_I=([0-9.+-e]+)", header)
4242
if len(ms) > 0:
4343
testnb = 1
4444
for m in ms:
@@ -122,16 +122,16 @@ def _monitorname_filename_match(dfolder, monname):
122122
look_for_filename = False
123123
lns = open(join(dfolder, "mccode.sim")).read().splitlines()
124124
for l in lns:
125-
if re.match(" component: %s$" % monname, l):
125+
if re.match(r" component: %s$" % monname, l):
126126
# flag this data section
127127
look_for_filename = True
128128
if look_for_filename:
129-
m = re.match("\s*filename:\s+(.+)", l)
129+
m = re.match(r"\s*filename:\s+(.+)", l)
130130
if m:
131131
filename = m.group(1)
132132
if os.path.isfile(join(dfolder,filename)):
133133
return filename
134-
if re.match("end data", l):
134+
if re.match(r"end data", l):
135135
# the filename can for 0D monitors be monname.dat
136136
zeroDfilename = join(dfolder, monname + ".dat")
137137
if os.path.isfile(zeroDfilename):
@@ -155,7 +155,7 @@ def extract_testvals(datafolder, monitorname):
155155
l = fp.readline()
156156
if not l:
157157
break
158-
m = re.match("# values: ([0-9+-e.]+) ([0-9+-e.]+) ([0-9]+)", l)
158+
m = re.match(r"# values: ([0-9+-e.]+) ([0-9+-e.]+) ([0-9]+)", l)
159159
if m :
160160
I = float(m.group(1))
161161
I_err = float(m.group(2))
@@ -325,7 +325,7 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, version=
325325
else:
326326
metalog = LineLogger()
327327
resfile = join(testdir,test.instrname,"run_stdout_%d.txt" % (test.testnb))
328-
cmd = "grep %s_I= %s | head -1 | cut -f2- -d= | cut -f1 -d\ " %(test.detector, resfile)
328+
cmd = r"grep %s_I= %s | head -1 | cut -f2- -d= | cut -f1 -d\ " %(test.detector, resfile)
329329
utils.run_subtool_to_completion(cmd, stdout_cb=metalog.logline)
330330
try:
331331
test.testval=float(metalog.lst[0])
@@ -344,7 +344,7 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, version=
344344
gpu_type = "none"
345345
if (platform.system() == "Linux"):
346346
metalog = LineLogger()
347-
utils.run_subtool_to_completion("nvidia-smi -L | head -1 |cut -f2- -d: |cut -f1 -d\(", stdout_cb=metalog.logline)
347+
utils.run_subtool_to_completion(r"nvidia-smi -L | head -1 |cut -f2- -d: |cut -f1 -d\(", stdout_cb=metalog.logline)
348348
gpu_type = ",".join(metalog.lst)
349349
if "failed because" in gpu_type:
350350
gpu_type = "none"
@@ -496,7 +496,7 @@ def deactivate_config(bckfile):
496496

497497
def extract_config_mccode_version(configfile):
498498
for l in open(configfile).read().splitlines():
499-
m = re.match("\s*\"MCCODE_VERSION\": (.+),", l)
499+
m = re.match(r"\s*\"MCCODE_VERSION\": (.+),", l)
500500
if m:
501501
return m.group(1).strip("\""), os.path.basename(os.path.dirname(configfile))
502502

@@ -511,9 +511,9 @@ def get_config_files(configfltr):
511511
for (_, _, files) in os.walk(lookin):
512512
print("Looking")
513513
if configfltr is not None:
514-
return [join(lookin, f) for f in files if re.search("^%s/mccode_config.json$" % configfltr, f)]
514+
return [join(lookin, f) for f in files if re.search(r"^%s/mccode_config.json$" % configfltr, f)]
515515
else:
516-
return [join(lookin, f) for f in files if re.search("^mccode_config.json$", f)]
516+
return [join(lookin, f) for f in files if re.search(r"^mccode_config.json$", f)]
517517

518518
# get test directory datetime string
519519
datetime = utils.get_datetimestr()

0 commit comments

Comments
 (0)