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/AutoGen/BuildEngine.py | 2 +- BaseTools/Source/Python/AutoGen/GenDepex.py | 2 +- BaseTools/Source/Python/AutoGen/GenMake.py | 2 +- BaseTools/Source/Python/AutoGen/IdfClassObject.py | 2 +- BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 4 ++-- BaseTools/Source/Python/AutoGen/StrGather.py | 2 +- BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'BaseTools/Source/Python/AutoGen') diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py index 752a1a1..45b39d7 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -306,7 +306,7 @@ class BuildRule: _SubSectionList = [_InputFile, _OutputFile, _Command] _PATH_SEP = "(+)" - _FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$") + _FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$") _BinaryFileRule = FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], [os.path.join("$(OUTPUT_DIR)", "${s_name}")], ["$(CP) ${src} ${dst}"], []) diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py index f2f2e9d..b6db664 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -126,7 +126,7 @@ class DependencyExpression: # # open and close brace must be taken as individual tokens # - TokenPattern = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)") + TokenPattern = re.compile(r"(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)") ## Constructor # diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index daec9c6..c416fe1 100755 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -28,7 +28,7 @@ from Common.DataType import TAB_COMPILER_MSFT gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE) ## Regular expression for matching macro used in header file inclusion -gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) +gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) gIsFileMap = {} diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py index a6b8123..bb413c6 100644 --- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py +++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py @@ -18,7 +18,7 @@ import os from Common.GlobalData import gIdentifierPattern from .UniClassObject import StripComments -IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) +IMAGE_TOKEN = re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) # # Value of different image information block types diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py index d05410b..65a2176 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -51,12 +51,12 @@ gInfSpecVersion = "0x00010017" # # Match name = variable # -gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)") +gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)") # # The format of guid in efivarstore statement likes following and must be correct: # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}} # -gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})") +gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\s*({.*?{.*?}\s*})") # # Template string to generic AsBuilt INF diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index eed3038..9789f50 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -54,7 +54,7 @@ NOT_REFERENCED = 'not referenced' COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED CHAR_ARRAY_DEFIN = 'unsigned char' COMMON_FILE_NAME = 'Strings' -STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) +STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) EFI_HII_ARRAY_SIZE_LENGTH = 4 EFI_HII_PACKAGE_HEADER_LENGTH = 4 diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py index f86c749..160e3a3 100644 --- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py @@ -26,7 +26,7 @@ from Common.Misc import * import json ## Regular expression for splitting Dependency Expression string into tokens -gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") +gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)") ## Regular expression for match: PCD(xxxx.yyy) gPCDAsGuidPattern = re.compile(r"^PCD\(.+\..+\)$") -- cgit v1.1