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/GenPatchPcdTable/GenPatchPcdTable.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py') diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index d962ab0add..8750db998f 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -31,7 +31,7 @@ __copyright__ = "Copyright (c) 2008 - 2018, Intel Corporation. All rights reserv #====================================== Internal Libraries ======================================== #============================================== Code =============================================== -symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE) +symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE) def parsePcdInfoFromMapFile(mapfilepath, efifilepath): """ Parse map file to get binary patch pcd information @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): if len(lines) == 0: return None firstline = lines[0].strip() - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline): + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline): return _parseForXcodeAndClang9(lines, efifilepath) if (firstline.startswith("Archive member included ") and firstline.endswith(" file (symbol)")): @@ -59,12 +59,12 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): return _parseGeneral(lines, efifilepath) def _parseForXcodeAndClang9(lines, efifilepath): - valuePattern = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') + valuePattern = re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') status = 0 pcds = [] for line in lines: line = line.strip() - if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ + if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ or line == "# Symbols:"): status = 1 continue @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath): def _parseForGCC(lines, efifilepath): """ Parse map file generated by GCC linker """ - dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$') + dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$') status = 0 imageBase = -1 sections = [] @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath): status = 0 #0 - beginning of file; 1 - PE section definition; 2 - symbol table secs = [] # key = section name bPcds = [] - symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)') + symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)') for line in lines: line = line.strip() -- cgit v1.2.3