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 <rebecca@bsdio.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Yuwei Chen <yuwei.chen@intel.com> Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com> Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
This commit is contained in:
committed by
mergify[bot]
parent
89705ad6c6
commit
9f0061a03b
@ -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()
|
||||
|
Reference in New Issue
Block a user