Skip to content

Commit c751a9c

Browse files
committedOct 4, 2023
Bug 1851988 - fix some python string escape sequences r=webdriver-reviewers,perftest-reviewers,whimboo,afinder,releng-reviewers,firefox-build-system-reviewers,ahal,sergesanspaille
Use r-strings or escape backslashes to avoid a deprecation warning. Differential Revision: https://phabricator.services.mozilla.com/D187655
1 parent c273706 commit c751a9c

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed
 

‎python/mozboot/mozboot/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def _parse_version_impl(self, path: Path, name, env, version_param):
494494
# path and move on.
495495
return None
496496

497-
match = re.search(name + " ([a-z0-9\.]+)", process.stdout)
497+
match = re.search(name + r" ([a-z0-9\.]+)", process.stdout)
498498
if not match:
499499
print("ERROR! Unable to identify %s version." % name)
500500
return None

‎remote/mach_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def testExpectation(self, testIdPattern, expected_name):
258258
if testIdPattern.find("*") == -1:
259259
return expected_name == testIdPattern
260260
else:
261-
return re.compile(re.escape(testIdPattern).replace("\*", ".*")).search(
261+
return re.compile(re.escape(testIdPattern).replace(r"\*", ".*")).search(
262262
expected_name
263263
)
264264

‎testing/mozharness/configs/unittests/win_unittest.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"Custom": 3,
3232
}.get("Best appearance")
3333
TASKBAR_AUTOHIDE_REG_PATH = {
34-
"Windows 7": "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2",
35-
"Windows 10": "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
34+
"Windows 7": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2",
35+
"Windows 10": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
3636
}.get("{} {}".format(platform.system(), platform.release()))
3737
#####
3838
config = {
@@ -258,7 +258,7 @@
258258
"cmd": [
259259
"powershell",
260260
"-command",
261-
"\"&{$p='HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}\"", # noqa
261+
"\"&{$p='HKCU:SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings\\Windows.SystemToast.SecurityAndMaintenance';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}\"", # noqa
262262
],
263263
"architectures": ["32bit", "64bit"],
264264
"halt_on_failure": True,
@@ -269,7 +269,7 @@
269269
"cmd": [
270270
"powershell",
271271
"-command",
272-
"\"&{{&Set-ItemProperty -Path 'HKCU:Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' -Name VisualFXSetting -Value {}}}\"".format(
272+
"\"&{{&Set-ItemProperty -Path 'HKCU:Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VisualEffects' -Name VisualFXSetting -Value {}}}\"".format(
273273
DESKTOP_VISUALFX_THEME
274274
),
275275
],
@@ -282,7 +282,7 @@
282282
"cmd": [
283283
"powershell",
284284
"-command",
285-
"New-ItemProperty -Path 'HKCU:\Control Panel\Accessibility' -Name 'DynamicScrollbars' -Value 0",
285+
"New-ItemProperty -Path 'HKCU:\\Control Panel\\Accessibility' -Name 'DynamicScrollbars' -Value 0",
286286
],
287287
"architectures": ["32bit", "64bit"],
288288
"halt_on_failure": False,
@@ -317,7 +317,7 @@
317317
"cmd": [
318318
"powershell",
319319
"-command",
320-
"if (test-path ${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe) {start chrome; Start-Sleep -s 30; taskkill /F /IM chrome.exe /T}",
320+
"if (test-path ${env:ProgramFiles(x86)}\\Google\\Chrome\\Application\\chrome.exe) {start chrome; Start-Sleep -s 30; taskkill /F /IM chrome.exe /T}",
321321
],
322322
"architectures": ["32bit", "64bit"],
323323
"halt_on_failure": True,

‎testing/mozharness/mach_commands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def path_to_url(self, path):
160160

161161
def _installer_url(self):
162162
package_re = {
163-
"linux": re.compile("^firefox-\d+\..+\.tar\.bz2$"),
164-
"win": re.compile("^firefox-\d+\..+\.installer\.exe$"),
165-
"mac": re.compile("^firefox-\d+\..+\.mac(?:64)?\.dmg$"),
163+
"linux": re.compile(r"^firefox-\d+\..+\.tar\.bz2$"),
164+
"win": re.compile(r"^firefox-\d+\..+\.installer\.exe$"),
165+
"mac": re.compile(r"^firefox-\d+\..+\.mac(?:64)?\.dmg$"),
166166
}[mozinfo.info["os"]]
167167
dist_path = os.path.join(self.topobjdir, "dist")
168168
filenames = [item for item in os.listdir(dist_path) if package_re.match(item)]

‎testing/mozharness/mozharness/base/errors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class VCSException(Exception):
8181

8282
VirtualenvErrorList = [
8383
{"substr": r"""not found or a compiler error:""", "level": WARNING},
84-
{"regex": re.compile("""\d+: error: """), "level": ERROR},
85-
{"regex": re.compile("""\d+: warning: """), "level": WARNING},
84+
{"regex": re.compile(r"""\d+: error: """), "level": ERROR},
85+
{"regex": re.compile(r"""\d+: warning: """), "level": WARNING},
8686
{
8787
"regex": re.compile(r"""Downloading .* \(.*\): *([0-9]+%)? *[0-9\.]+[kmKM]b"""),
8888
"level": DEBUG,

‎testing/mozharness/mozharness/mozilla/testing/android.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def dump_perf_info(self):
337337
# low bogomips can be a good predictor of that condition.
338338
bogomips_minimum = int(self.config.get("bogomips_minimum") or 0)
339339
for line in cpuinfo.split("\n"):
340-
m = re.match("BogoMIPS.*: (\d*)", line, re.IGNORECASE)
340+
m = re.match(r"BogoMIPS.*: (\d*)", line, re.IGNORECASE)
341341
if m:
342342
bogomips = int(m.group(1))
343343
if bogomips_minimum > 0 and bogomips < bogomips_minimum:

‎testing/mozharness/mozharness/mozilla/testing/errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
TestPassed = [
117117
{
118-
"regex": re.compile("""(TEST-INFO|TEST-KNOWN-FAIL|TEST-PASS|INFO \| )"""),
118+
"regex": re.compile(r"""(TEST-INFO|TEST-KNOWN-FAIL|TEST-PASS|INFO \| )"""),
119119
"level": INFO,
120120
},
121121
]

‎testing/xpcshell/xpcshellcommandline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def add_common_arguments(parser):
1313
type=str,
1414
dest="app_binary",
1515
default=None,
16-
help="path to application binary (eg: c:\program files\mozilla firefox\firefox.exe)",
16+
help="path to application binary (eg: c:\\program files\\mozilla firefox\\firefox.exe)",
1717
)
1818
parser.add_argument(
1919
"--app-path",

‎tools/browsertime/mach_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def extract_browser_name(args):
500500
"Extracts the browser name if any"
501501
# These are BT arguments, it's BT job to check them
502502
# here we just want to extract the browser name
503-
res = re.findall("(--browser|-b)[= ]([\w]+)", " ".join(args))
503+
res = re.findall(r"(--browser|-b)[= ]([\w]+)", " ".join(args))
504504
if res == []:
505505
return None
506506
return res[0][-1]

‎tools/esmify/mach_commands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def load_exclusion_files():
147147
for path in EXCLUSION_FILES:
148148
with open(path, "r") as f:
149149
for line in f:
150-
p = path_sep_to_native(re.sub("\*$", "", line.strip()))
150+
p = path_sep_to_native(re.sub(r"\*$", "", line.strip()))
151151
excluded_from_imports_prefix.append(p)
152152

153153

@@ -197,7 +197,7 @@ def find_jsms(self, path):
197197
cmd = [
198198
"hg",
199199
"files",
200-
f"set:grep('EXPORTED_SYMBOLS = \[') and glob:\"{path}/**/*.js\"",
200+
rf"set:grep('EXPORTED_SYMBOLS = \[') and glob:\"{path}/**/*.js\"",
201201
]
202202
for line in self.run(cmd):
203203
jsm = pathlib.Path(line)
@@ -247,7 +247,7 @@ def find_jsms(self, path):
247247
jsms.append(jsm)
248248

249249
handled = {}
250-
cmd = ["git", "grep", "EXPORTED_SYMBOLS = \[", f"{path}/*.js"]
250+
cmd = ["git", "grep", "EXPORTED_SYMBOLS = \\[", f"{path}/*.js"]
251251
for line in self.run(cmd):
252252
m = re.search("^([^:]+):", line)
253253
if not m:

0 commit comments

Comments
 (0)
Failed to load comments.