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
This commit is contained in:
Julien Cristau 2023-10-04 09:49:09 +00:00
Родитель 77a4efeeae
Коммит 93630da8b8
10 изменённых файлов: 20 добавлений и 20 удалений

Просмотреть файл

@ -494,7 +494,7 @@ class BaseBootstrapper(object):
# path and move on.
return None
match = re.search(name + " ([a-z0-9\.]+)", process.stdout)
match = re.search(name + r" ([a-z0-9\.]+)", process.stdout)
if not match:
print("ERROR! Unable to identify %s version." % name)
return None

Просмотреть файл

@ -258,7 +258,7 @@ class MochaOutputHandler(object):
if testIdPattern.find("*") == -1:
return expected_name == testIdPattern
else:
return re.compile(re.escape(testIdPattern).replace("\*", ".*")).search(
return re.compile(re.escape(testIdPattern).replace(r"\*", ".*")).search(
expected_name
)

Просмотреть файл

@ -31,8 +31,8 @@ DESKTOP_VISUALFX_THEME = {
"Custom": 3,
}.get("Best appearance")
TASKBAR_AUTOHIDE_REG_PATH = {
"Windows 7": "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2",
"Windows 10": "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
"Windows 7": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2",
"Windows 10": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
}.get("{} {}".format(platform.system(), platform.release()))
#####
config = {
@ -258,7 +258,7 @@ config = {
"cmd": [
"powershell",
"-command",
"\"&{$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
"\"&{$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
],
"architectures": ["32bit", "64bit"],
"halt_on_failure": True,
@ -269,7 +269,7 @@ config = {
"cmd": [
"powershell",
"-command",
"\"&{{&Set-ItemProperty -Path 'HKCU:Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' -Name VisualFXSetting -Value {}}}\"".format(
"\"&{{&Set-ItemProperty -Path 'HKCU:Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VisualEffects' -Name VisualFXSetting -Value {}}}\"".format(
DESKTOP_VISUALFX_THEME
),
],
@ -282,7 +282,7 @@ config = {
"cmd": [
"powershell",
"-command",
"New-ItemProperty -Path 'HKCU:\Control Panel\Accessibility' -Name 'DynamicScrollbars' -Value 0",
"New-ItemProperty -Path 'HKCU:\\Control Panel\\Accessibility' -Name 'DynamicScrollbars' -Value 0",
],
"architectures": ["32bit", "64bit"],
"halt_on_failure": False,
@ -317,7 +317,7 @@ config = {
"cmd": [
"powershell",
"-command",
"if (test-path ${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe) {start chrome; Start-Sleep -s 30; taskkill /F /IM chrome.exe /T}",
"if (test-path ${env:ProgramFiles(x86)}\\Google\\Chrome\\Application\\chrome.exe) {start chrome; Start-Sleep -s 30; taskkill /F /IM chrome.exe /T}",
],
"architectures": ["32bit", "64bit"],
"halt_on_failure": True,

Просмотреть файл

@ -160,9 +160,9 @@ class MozharnessRunner(MozbuildObject):
def _installer_url(self):
package_re = {
"linux": re.compile("^firefox-\d+\..+\.tar\.bz2$"),
"win": re.compile("^firefox-\d+\..+\.installer\.exe$"),
"mac": re.compile("^firefox-\d+\..+\.mac(?:64)?\.dmg$"),
"linux": re.compile(r"^firefox-\d+\..+\.tar\.bz2$"),
"win": re.compile(r"^firefox-\d+\..+\.installer\.exe$"),
"mac": re.compile(r"^firefox-\d+\..+\.mac(?:64)?\.dmg$"),
}[mozinfo.info["os"]]
dist_path = os.path.join(self.topobjdir, "dist")
filenames = [item for item in os.listdir(dist_path) if package_re.match(item)]

Просмотреть файл

@ -81,8 +81,8 @@ PythonErrorList = BaseErrorList + [
VirtualenvErrorList = [
{"substr": r"""not found or a compiler error:""", "level": WARNING},
{"regex": re.compile("""\d+: error: """), "level": ERROR},
{"regex": re.compile("""\d+: warning: """), "level": WARNING},
{"regex": re.compile(r"""\d+: error: """), "level": ERROR},
{"regex": re.compile(r"""\d+: warning: """), "level": WARNING},
{
"regex": re.compile(r"""Downloading .* \(.*\): *([0-9]+%)? *[0-9\.]+[kmKM]b"""),
"level": DEBUG,

Просмотреть файл

@ -337,7 +337,7 @@ class AndroidMixin(object):
# low bogomips can be a good predictor of that condition.
bogomips_minimum = int(self.config.get("bogomips_minimum") or 0)
for line in cpuinfo.split("\n"):
m = re.match("BogoMIPS.*: (\d*)", line, re.IGNORECASE)
m = re.match(r"BogoMIPS.*: (\d*)", line, re.IGNORECASE)
if m:
bogomips = int(m.group(1))
if bogomips_minimum > 0 and bogomips < bogomips_minimum:

Просмотреть файл

@ -115,7 +115,7 @@ TinderBoxPrintRe = {
TestPassed = [
{
"regex": re.compile("""(TEST-INFO|TEST-KNOWN-FAIL|TEST-PASS|INFO \| )"""),
"regex": re.compile(r"""(TEST-INFO|TEST-KNOWN-FAIL|TEST-PASS|INFO \| )"""),
"level": INFO,
},
]

Просмотреть файл

@ -13,7 +13,7 @@ def add_common_arguments(parser):
type=str,
dest="app_binary",
default=None,
help="path to application binary (eg: c:\program files\mozilla firefox\firefox.exe)",
help="path to application binary (eg: c:\\program files\\mozilla firefox\\firefox.exe)",
)
parser.add_argument(
"--app-path",

Просмотреть файл

@ -500,7 +500,7 @@ def extra_default_args(command_context, args=[]):
"Extracts the browser name if any"
# These are BT arguments, it's BT job to check them
# here we just want to extract the browser name
res = re.findall("(--browser|-b)[= ]([\w]+)", " ".join(args))
res = re.findall(r"(--browser|-b)[= ]([\w]+)", " ".join(args))
if res == []:
return None
return res[0][-1]

Просмотреть файл

@ -147,7 +147,7 @@ def load_exclusion_files():
for path in EXCLUSION_FILES:
with open(path, "r") as f:
for line in f:
p = path_sep_to_native(re.sub("\*$", "", line.strip()))
p = path_sep_to_native(re.sub(r"\*$", "", line.strip()))
excluded_from_imports_prefix.append(p)
@ -197,7 +197,7 @@ class HgUtils(VCSUtils):
cmd = [
"hg",
"files",
f"set:grep('EXPORTED_SYMBOLS = \[') and glob:\"{path}/**/*.js\"",
rf"set:grep('EXPORTED_SYMBOLS = \[') and glob:\"{path}/**/*.js\"",
]
for line in self.run(cmd):
jsm = pathlib.Path(line)
@ -247,7 +247,7 @@ class GitUtils(VCSUtils):
jsms.append(jsm)
handled = {}
cmd = ["git", "grep", "EXPORTED_SYMBOLS = \[", f"{path}/*.js"]
cmd = ["git", "grep", "EXPORTED_SYMBOLS = \\[", f"{path}/*.js"]
for line in self.run(cmd):
m = re.search("^([^:]+):", line)
if not m: