From 9f0061a03b61d282fbc0ba5be22155d06a5e64a1 Mon Sep 17 00:00:00 2001 From: "Joey Vagedes via groups.io" Date: Wed, 6 Dec 2023 12:27:02 -0800 Subject: BaseTools: Resolve regex syntax warnings Switches regex patterns to raw text to resolve python 3.12 syntax warnings in regards to invalid escape sequences, as is suggested by the re (regex) module in python. Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Cc: Yuwei Chen Signed-off-by: Joey Vagedes Reviewed-by: Rebecca Cran --- BaseTools/Source/Python/Trim/Trim.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'BaseTools/Source/Python/Trim/Trim.py') diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py index 416935df5e..6d7bc05510 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -28,15 +28,15 @@ __version__ = "%prog Version " + __version_number__ __copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights reserved." ## Regular expression for matching Line Control directive like "#line xxx" -gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"') +gLineControlDirective = re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"') ## Regular expression for matching "typedef struct" -gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE) +gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE) ## Regular expression for matching "#pragma pack" -gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE) +gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE) ## Regular expression for matching "typedef" -gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE) +gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE) ## Regular expression for matching "typedef struct, typedef union, struct, union" -gTypedef_MulPattern = re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE) +gTypedef_MulPattern = re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE) # # The following number pattern match will only match if following criteria is met: @@ -44,14 +44,14 @@ gTypedef_MulPattern = re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{] # as the pattern is greedily match, so it is ok for the gDecNumberPattern or gHexNumberPattern to grab the maximum match # ## Regular expression for matching HEX number -gHexNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?") +gHexNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?") ## Regular expression for matching decimal number with 'U' postfix -gDecNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])") +gDecNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])") ## Regular expression for matching constant with 'ULL' 'LL' postfix -gLongNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])") +gLongNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])") ## Regular expression for matching "Include ()" in asl file -gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE) +gAslIncludePattern = re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE) ## Regular expression for matching C style #include "XXX.asl" in asl file gAslCIncludePattern = re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*([>"])', re.MULTILINE) ## Patterns used to convert EDK conventions to EDK2 ECP conventions -- cgit v1.2.3