From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 158C9740032 for ; Wed, 6 Dec 2023 20:27:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ikJHxgjHHiGvS0gz2XheRyn6Uw3MyDq95iEslMf8rcc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701894437; v=1; b=bHWRHR4q5LW/zz4AgVq0wjytVknviAHeuAaOYr6rsPt6jPJr2uOG9jXc/WbBe70/Baelj5nk ySPiqUwLxfsKP5/LJD+IgoaR22uTT5mLPZ8m+W5ZuntAVZb+fxTq/+MJiqZ5eYR7FM9cQHUd60D 6GuEKpbHG29ic9fqoaLohE1o= X-Received: by 127.0.0.2 with SMTP id nrLyYY7687511xwUAqPKXv8C; Wed, 06 Dec 2023 12:27:17 -0800 X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mx.groups.io with SMTP id smtpd.web10.44220.1701894437276273192 for ; Wed, 06 Dec 2023 12:27:17 -0800 X-Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-28862fdfb44so216086a91.0 for ; Wed, 06 Dec 2023 12:27:17 -0800 (PST) X-Gm-Message-State: 2crtyZM6sbxjF0DFDvvr9mDOx7686176AA= X-Google-Smtp-Source: AGHT+IFT/pyXqmSmN08mVpntgrFBbQ9/GuWq4uFTtoNjDtBeoGyxr5tz4YhR6e+9k4PpV8g83d6tKg== X-Received: by 2002:a17:90b:1d90:b0:286:e66b:8a13 with SMTP id pf16-20020a17090b1d9000b00286e66b8a13mr1278054pjb.33.1701894436052; Wed, 06 Dec 2023 12:27:16 -0800 (PST) X-Received: from localhost.localdomain (c-174-164-102-13.hsd1.wa.comcast.net. [174.164.102.13]) by smtp.gmail.com with ESMTPSA id gz9-20020a17090b0ec900b00286dae0ac84sm269868pjb.46.2023.12.06.12.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 12:27:15 -0800 (PST) From: "Joey Vagedes via groups.io" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng , Yuwei Chen Subject: [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings Date: Wed, 6 Dec 2023 12:27:02 -0800 Message-ID: <20231206202703.1568-2-joey.vagedes@gmail.com> In-Reply-To: <20231206202703.1568-1-joey.vagedes@gmail.com> References: <20231206202703.1568-1-joey.vagedes@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,joeyvagedes@microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=bHWRHR4q; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- BaseTools/Source/Python/AmlToC/AmlToC.py | 2 +- 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 +- BaseTools/Source/Python/Common/Expression.py | 16 ++++++--= ----- BaseTools/Source/Python/Common/GlobalData.py | 4 ++-- BaseTools/Source/Python/Common/Misc.py | 24 ++++++++= ++---------- BaseTools/Source/Python/Common/ToolDefClassObject.py | 6 ++--- BaseTools/Source/Python/GenFds/FdfParser.py | 10 ++++---- BaseTools/Source/Python/GenFds/GenFds.py | 2 +- BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 12 +++++---= -- BaseTools/Source/Python/Trim/Trim.py | 18 +++++++-= ------- BaseTools/Source/Python/Workspace/DscBuildData.py | 8 +++---- BaseTools/Source/Python/Workspace/MetaFileParser.py | 2 +- 18 files changed, 60 insertions(+), 60 deletions(-) diff --git a/BaseTools/Source/Python/AmlToC/AmlToC.py b/BaseTools/Source/Py= thon/AmlToC/AmlToC.py index 346de7159de7..63931c9720c9 100644 --- a/BaseTools/Source/Python/AmlToC/AmlToC.py +++ b/BaseTools/Source/Python/AmlToC/AmlToC.py @@ -17,7 +17,7 @@ from Common.BuildToolError import * import sys=0D import os=0D =0D -__description__ =3D """=0D +__description__ =3D r"""=0D Convert an AML file to a .c file containing the AML bytecode stored in a C= =0D array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c.=0D Tables\Dsdt.c will contain a C array named "dsdt_aml_code" that contains=0D diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/Python/AutoGen/BuildEngine.py index 752a1a1f6a86..45b39d7878d5 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -306,7 +306,7 @@ class BuildRule: _SubSectionList =3D [_InputFile, _OutputFile, _Command]=0D =0D _PATH_SEP =3D "(+)"=0D - _FileTypePattern =3D re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")=0D + _FileTypePattern =3D re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")=0D _BinaryFileRule =3D FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], [os.pat= h.join("$(OUTPUT_DIR)", "${s_name}")],=0D ["$(CP) ${src} ${dst}"], [])=0D =0D diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source= /Python/AutoGen/GenDepex.py index f2f2e9d65b5f..b6db6645a4fb 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -126,7 +126,7 @@ class DependencyExpression: #=0D # open and close brace must be taken as individual tokens=0D #=0D - TokenPattern =3D re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")= =0D + TokenPattern =3D re.compile(r"(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")= =0D =0D ## Constructor=0D #=0D diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index daec9c6d54b2..c416fe172fe5 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 =3D re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?= :\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)= ?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)=0D =0D ## Regular expression for matching macro used in header file inclusion=0D -gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICOD= E)=0D +gMacroPattern =3D re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICO= DE)=0D =0D gIsFileMap =3D {}=0D =0D diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/= Source/Python/AutoGen/IdfClassObject.py index a6b8123c2539..bb413c6a26e3 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=0D from .UniClassObject import StripComments=0D =0D -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE= | re.UNICODE)=0D +IMAGE_TOKEN =3D re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILIN= E | re.UNICODE)=0D =0D #=0D # Value of different image information block types=0D diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index d05410b32966..65a2176ca982 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -51,12 +51,12 @@ gInfSpecVersion =3D "0x00010017" #=0D # Match name =3D variable=0D #=0D -gEfiVarStoreNamePattern =3D re.compile("\s*name\s*=3D\s*(\w+)")=0D +gEfiVarStoreNamePattern =3D re.compile(r"\s*name\s*=3D\s*(\w+)")=0D #=0D # The format of guid in efivarstore statement likes following and must be = correct:=0D # guid =3D {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x0= 2, 0x11, 0x3D}}=0D #=0D -gEfiVarStoreGuidPattern =3D re.compile("\s*guid\s*=3D\s*({.*?{.*?}\s*})")= =0D +gEfiVarStoreGuidPattern =3D re.compile(r"\s*guid\s*=3D\s*({.*?{.*?}\s*})")= =0D =0D #=0D # Template string to generic AsBuilt INF=0D diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Sourc= e/Python/AutoGen/StrGather.py index eed30388bea1..9789f50ba4db 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -54,7 +54,7 @@ NOT_REFERENCED =3D 'not referenced' COMMENT_NOT_REFERENCED =3D ' ' + COMMENT + NOT_REFERENCED=0D CHAR_ARRAY_DEFIN =3D 'unsigned char'=0D COMMON_FILE_NAME =3D 'Strings'=0D -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILI= NE | re.UNICODE)=0D +STRING_TOKEN =3D re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTIL= INE | re.UNICODE)=0D =0D EFI_HII_ARRAY_SIZE_LENGTH =3D 4=0D EFI_HII_PACKAGE_HEADER_LENGTH =3D 4=0D diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTool= s/Source/Python/AutoGen/WorkspaceAutoGen.py index f86c749c08c3..160e3a3cd321 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=0D =0D ## Regular expression for splitting Dependency Expression string into toke= ns=0D -gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)")=0D +gDepexTokenPattern =3D re.compile(r"(\(|\)|\w+| \S+\.inf)")=0D =0D ## Regular expression for match: PCD(xxxx.yyy)=0D gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$")=0D diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index b62efe6f9be6..9d9cb0c92962 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -41,8 +41,8 @@ ERR_EMPTY_EXPR =3D 'Empty expression is not allo= wed.' ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY= ), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'=0D =0D __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')=0D -_ReLabel =3D re.compile('LABEL\((\w+)\)')=0D -_ReOffset =3D re.compile('OFFSET_OF\((\w+)\)')=0D +_ReLabel =3D re.compile(r'LABEL\((\w+)\)')=0D +_ReOffset =3D re.compile(r'OFFSET_OF\((\w+)\)')=0D PcdPattern =3D re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]= *$')=0D =0D ## SplitString=0D @@ -242,10 +242,10 @@ class ValueExpression(BaseExpression): =0D =0D SymbolPattern =3D re.compile("("=0D - "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+= \.\w+|"=0D - "&&|\|\||!(?!=3D)|"=0D - "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)= |(?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|"=0D - "(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|= (?<=3D\W)GT(?=3D\W)|(?<=3D\W)LT(?=3D\W)|(?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?= =3D\W)"=0D + r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w= +\.\w+|"=0D + r"&&|\|\||!(?!=3D)|"=0D + r"(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W= )|(?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|"=0D + r"(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)= |(?<=3D\W)GT(?=3D\W)|(?<=3D\W)LT(?=3D\W)|(?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?= =3D\W)"=0D ")")=0D =0D @staticmethod=0D @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression): self._Token =3D "'" + UStr + "'"=0D return self._Token=0D elif Expr.startswith('UINT'):=0D - Re =3D re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')=0D + Re =3D re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')=0D try:=0D RetValue =3D Re.search(Expr).group(1)=0D except:=0D @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression): TokenSpaceGuidName =3D ''=0D if Item.startswith(TAB_GUID) and Item.ends= with(')'):=0D try:=0D - TokenSpaceGuidName =3D re.search('= GUID\((\w+)\)', Item).group(1)=0D + TokenSpaceGuidName =3D re.search(r= 'GUID\((\w+)\)', Item).group(1)=0D except:=0D pass=0D if TokenSpaceGuidName and TokenSpaceGu= idName in self._Symb:=0D diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index 197bd8366682..11849e863f53 100755 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -33,10 +33,10 @@ gDefaultStores =3D [] gGuidDict =3D {}=0D =0D # definition for a MACRO name. used to create regular expressions below.= =0D -_MacroNamePattern =3D "[A-Z][A-Z0-9_]*"=0D +_MacroNamePattern =3D r"[A-Z][A-Z0-9_]*"=0D =0D ## Regular expression for matching macro used in DSC/DEC/INF file inclusio= n=0D -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroNamePattern), re= .UNICODE)=0D +gMacroRefPattern =3D re.compile(r"\$\(({})\)".format(_MacroNamePattern), r= e.UNICODE)=0D gMacroDefPattern =3D re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")=0D gMacroNamePattern =3D re.compile("^{}$".format(_MacroNamePattern))=0D =0D diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 4be7957138a5..f87d9dbdba39 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -41,16 +41,16 @@ from CommonDataClass.Exceptions import BadExpression from Common.caching import cached_property=0D import struct=0D =0D -ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")=0D +ArrayIndex =3D re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")=0D ## Regular expression used to find out place holders in string template=0D -gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.= UNICODE)=0D +gPlaceholderPattern =3D re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE | re= .UNICODE)=0D =0D ## regular expressions for map file processing=0D -startPatternGeneral =3D re.compile("^Start[' ']+Length[' ']+Name[' ']+Clas= s")=0D -addressPatternGeneral =3D re.compile("^Address[' ']+Publics by Value[' ']+= Rva\+Base")=0D -valuePatternGcc =3D re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+= )$')=0D -pcdPatternGcc =3D re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')=0D -secReGeneral =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[H= h]? +([.\w\$]+) +(\w+)', re.UNICODE)=0D +startPatternGeneral =3D re.compile(r"^Start[' ']+Length[' ']+Name[' ']+Cla= ss")=0D +addressPatternGeneral =3D re.compile(r"^Address[' ']+Publics by Value[' ']= +Rva\+Base")=0D +valuePatternGcc =3D re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]= +)$')=0D +pcdPatternGcc =3D re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')=0D +secReGeneral =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[= Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)=0D =0D StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')=0D =0D @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames): =0D if len(lines) =3D=3D 0: return None=0D firstline =3D lines[0].strip()=0D - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firs= tline):=0D + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fir= stline):=0D return _parseForXcodeAndClang9(lines, efifilepath, varnames)=0D if (firstline.startswith("Archive member included ") and=0D firstline.endswith(" file (symbol)")):=0D @@ -96,7 +96,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varnames): ret =3D []=0D for line in lines:=0D line =3D line.strip()=0D - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) \=0D + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Ou= t\s*In\s*Symbol\s*$', line) \=0D or line =3D=3D "# Symbols:"):=0D status =3D 1=0D continue=0D @@ -104,7 +104,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varname= s): for varname in varnames:=0D if varname in line:=0D # cannot pregenerate this RegEx since it uses varname = from varnames.=0D - m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % = varname, line)=0D + m =3D re.match(r'^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' %= varname, line)=0D if m is not None:=0D ret.append((varname, m.group(1)))=0D return ret=0D @@ -170,7 +170,7 @@ def _parseGeneral(lines, efifilepath, varnames): status =3D 0 #0 - beginning of file; 1 - PE section definition; 2 -= symbol table=0D secs =3D [] # key =3D section name=0D varoffset =3D []=0D - symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]= +) +([\da-fA-F]+)', re.UNICODE)=0D + symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-= ]+) +([\da-fA-F]+)', re.UNICODE)=0D =0D for line in lines:=0D line =3D line.strip()=0D @@ -1926,4 +1926,4 @@ def CopyDict(ori_dict): # Remove the c/c++ comments: // and /* */=0D #=0D def RemoveCComments(ctext):=0D - return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S)=0D + return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S)=0D diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseToo= ls/Source/Python/Common/ToolDefClassObject.py index 2b4b23849196..afc20a3c1719 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -30,9 +30,9 @@ from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEF= INES_TOOL_CHAIN_TAG,\ ##=0D # Static variables used for pattern=0D #=0D -gMacroRefPattern =3D re.compile('(DEF\([^\(\)]+\))')=0D -gEnvRefPattern =3D re.compile('(ENV\([^\(\)]+\))')=0D -gMacroDefPattern =3D re.compile("DEFINE\s+([^\s]+)")=0D +gMacroRefPattern =3D re.compile(r'(DEF\([^\(\)]+\))')=0D +gEnvRefPattern =3D re.compile(r'(ENV\([^\(\)]+\))')=0D +gMacroDefPattern =3D re.compile(r"DEFINE\s+([^\s]+)")=0D gDefaultToolsDefFile =3D "tools_def.txt"=0D =0D ## ToolDefClassObject=0D diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index a9a14ca2bb33..feb4c727794f 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -65,11 +65,11 @@ ALIGNMENTS =3D {"Auto", "8", "16", "32", "64", "128", "= 512", "1K", "4K", "32K", "6 ALIGNMENT_NOAUTO =3D ALIGNMENTS - {"Auto"}=0D CR_LB_SET =3D {T_CHAR_CR, TAB_LINE_BREAK}=0D =0D -RegionSizePattern =3D compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*= (?P(?:0x|0X)?[a-fA-F0-9]+)\s*")=0D -RegionSizeGuidPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s= *(?P\w+\.\w+[\.\w\[\]]*)\s*")=0D -RegionOffsetPcdPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$")= =0D -ShortcutPcdPattern =3D compile("\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-F= 0-9]+)\s*\|\s*(?P\w+\.\w+)\s*")=0D -BaseAddrValuePattern =3D compile('^0[xX][0-9a-fA-F]+')=0D +RegionSizePattern =3D compile(r"\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s= *(?P(?:0x|0X)?[a-fA-F0-9]+)\s*")=0D +RegionSizeGuidPattern =3D compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\= s*(?P\w+\.\w+[\.\w\[\]]*)\s*")=0D +RegionOffsetPcdPattern =3D compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$"= )=0D +ShortcutPcdPattern =3D compile(r"\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-= F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*")=0D +BaseAddrValuePattern =3D compile(r'^0[xX][0-9a-fA-F]+')=0D FileExtensionPattern =3D compile(r'([a-zA-Z][a-zA-Z0-9]*)')=0D TokenFindPattern =3D compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-= 9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')=0D AllIncludeFileList =3D []=0D diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 17b71b7cd347..b48fe761e051 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -733,7 +733,7 @@ class GenFds(object): if not os.path.exists(FfsPath[0]):=0D continue=0D MatchDict =3D {}=0D - ReFileEnds =3D compile('\S+(.ui)$|\S+(fv.sec.txt)$= |\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$= ')=0D + ReFileEnds =3D compile(r'\S+(.ui)$|\S+(fv.sec.txt)= $|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)= $')=0D FileList =3D os.listdir(FfsPath[0])=0D for File in FileList:=0D Match =3D ReFileEnds.search(File)=0D diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b= /BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index d962ab0adda7..8750db998ffc 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -31,7 +31,7 @@ __copyright__ =3D "Copyright (c) 2008 - 2018, Intel Corpo= ration. All rights reserv #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Internal Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D =0D #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Code =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D -symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+= ) +([\da-fA-F]+)', re.UNICODE)=0D +symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]= +) +([\da-fA-F]+)', re.UNICODE)=0D =0D def parsePcdInfoFromMapFile(mapfilepath, efifilepath):=0D """ Parse map file to get binary patch pcd information=0D @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): =0D if len(lines) =3D=3D 0: return None=0D firstline =3D lines[0].strip()=0D - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firs= tline):=0D + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fir= stline):=0D return _parseForXcodeAndClang9(lines, efifilepath)=0D if (firstline.startswith("Archive member included ") and=0D firstline.endswith(" file (symbol)")):=0D @@ -59,12 +59,12 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): return _parseGeneral(lines, efifilepath)=0D =0D def _parseForXcodeAndClang9(lines, efifilepath):=0D - valuePattern =3D re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Binar= yPatch_([\w]+))')=0D + valuePattern =3D re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Bina= ryPatch_([\w]+))')=0D status =3D 0=0D pcds =3D []=0D for line in lines:=0D line =3D line.strip()=0D - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) \=0D + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Ou= t\s*In\s*Symbol\s*$', line) \=0D or line =3D=3D "# Symbols:"):=0D status =3D 1=0D continue=0D @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath): =0D def _parseForGCC(lines, efifilepath):=0D """ Parse map file generated by GCC linker """=0D - dataPattern =3D re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')=0D + dataPattern =3D re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')=0D status =3D 0=0D imageBase =3D -1=0D sections =3D []=0D @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath): status =3D 0 #0 - beginning of file; 1 - PE section definition; 2 -= symbol table=0D secs =3D [] # key =3D section name=0D bPcds =3D []=0D - symPattern =3D re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')=0D + symPattern =3D re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')=0D =0D for line in lines:=0D line =3D line.strip()=0D diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index 416935df5e90..6d7bc0551026 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -28,15 +28,15 @@ __version__ =3D "%prog Version " + __version_number__ __copyright__ =3D "Copyright (c) 2007-2018, Intel Corporation. All rights = reserved."=0D =0D ## Regular expression for matching Line Control directive like "#line xxx"= =0D -gLineControlDirective =3D re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*= )"')=0D +gLineControlDirective =3D re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]= *)"')=0D ## Regular expression for matching "typedef struct"=0D -gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re= .MULTILINE)=0D +gTypedefPattern =3D re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", r= e.MULTILINE)=0D ## Regular expression for matching "#pragma pack"=0D -gPragmaPattern =3D re.compile("^\s*#pragma\s+pack", re.MULTILINE)=0D +gPragmaPattern =3D re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)=0D ## Regular expression for matching "typedef"=0D -gTypedef_SinglePattern =3D re.compile("^\s*typedef", re.MULTILINE)=0D +gTypedef_SinglePattern =3D re.compile(r"^\s*typedef", re.MULTILINE)=0D ## Regular expression for matching "typedef struct, typedef union, struct,= union"=0D -gTypedef_MulPattern =3D re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+= )?\s*[{]*$", re.MULTILINE)=0D +gTypedef_MulPattern =3D re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+\w= +)?\s*[{]*$", re.MULTILINE)=0D =0D #=0D # The following number pattern match will only match if following criteria= is met:=0D @@ -44,14 +44,14 @@ gTypedef_MulPattern =3D re.compile("^\s*(typedef)?\s+(s= truct|union)(\s+\w+)?\s*[{] # as the pattern is greedily match, so it is ok for the gDecNumberPattern = or gHexNumberPattern to grab the maximum match=0D #=0D ## Regular expression for matching HEX number=0D -gHexNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+= )(U(?=3D$|[^a-zA-Z0-9_]))?")=0D +gHexNumberPattern =3D re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]= +)(U(?=3D$|[^a-zA-Z0-9_]))?")=0D ## Regular expression for matching decimal number with 'U' postfix=0D -gDecNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-= zA-Z0-9_])")=0D +gDecNumberPattern =3D re.compile(r"(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a= -zA-Z0-9_])")=0D ## Regular expression for matching constant with 'ULL' 'LL' postfix=0D -gLongNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|= [0-9]+)U?LL(?=3D$|[^a-zA-Z0-9_])")=0D +gLongNumberPattern =3D re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+= |[0-9]+)U?LL(?=3D$|[^a-zA-Z0-9_])")=0D =0D ## Regular expression for matching "Include ()" in asl file=0D -gAslIncludePattern =3D re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\= )", re.MULTILINE)=0D +gAslIncludePattern =3D re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"= \)", re.MULTILINE)=0D ## Regular expression for matching C style #include "XXX.asl" in asl file= =0D gAslCIncludePattern =3D re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\= s*([>"])', re.MULTILINE)=0D ## Patterns used to convert EDK conventions to EDK2 ECP conventions=0D diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 8fd949dc50b6..817cdbe5f19c 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -90,7 +90,7 @@ PcdMakefileHeader =3D ''' =0D WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 '=0D LinuxCFLAGS =3D 'CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-variable= '=0D -PcdMakefileEnd =3D '''=0D +PcdMakefileEnd =3D r'''=0D !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common=0D !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app=0D '''=0D @@ -110,7 +110,7 @@ LIBS =3D -lCommon variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')=0D SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')=0D ## regular expressions for finding decimal and hex numbers=0D -Pattern =3D re.compile('^[1-9]\d*|0$')=0D +Pattern =3D re.compile(r'^[1-9]\d*|0$')=0D HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$')=0D ## Regular expression for finding header file inclusions=0D from AutoGen.GenMake import gIncludePattern=0D @@ -2840,7 +2840,7 @@ class DscBuildData(PlatformBuildClassObject): # start generating makefile=0D MakeApp =3D PcdMakefileHeader=0D if sys.platform =3D=3D "win32":=0D - MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Output= Path, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECT= S =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.joi= n(self.OutputPath, PcdValueCommonName)) + 'INC =3D '=0D + MakeApp =3D MakeApp + r'APPFILE =3D %s\%s.exe\n' % (self.Outpu= tPath, PcdValueInitName) + r'APPNAME =3D %s\n' % (PcdValueInitName) + r'OBJ= ECTS =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.= join(self.OutputPath, PcdValueCommonName)) + 'INC =3D '=0D else:=0D MakeApp =3D MakeApp + PcdGccMakefile=0D MakeApp =3D MakeApp + 'APPFILE =3D %s/%s\n' % (self.OutputPath= , PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECTS = =3D %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(self= .OutputPath, PcdValueCommonName)) + \=0D @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject): MakeApp +=3D "$(OBJECTS) : %s\n" % include_file=0D if sys.platform =3D=3D "win32":=0D PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData.gG= lobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c"))=0D - MakeApp =3D MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.Out= putPath, PcdValueCommonPath)=0D + MakeApp =3D MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.Ou= tputPath, PcdValueCommonPath)=0D MakeApp =3D MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPat= h)=0D else:=0D PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData.gG= lobalDefines["EDK_TOOLS_PATH"], "Source/C/Common/PcdValueCommon.c"))=0D diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index 3508591b281e..73a1654edb30 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1897,7 +1897,7 @@ class DecParser(MetaFileParser): self._SectionType =3D []=0D ArchList =3D set()=0D PrivateList =3D set()=0D - Line =3D re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)=0D + Line =3D re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)=0D for Item in Line[1:-1].split(TAB_COMMA_SPLIT):=0D if Item =3D=3D '':=0D EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,=0D --=20 2.43.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112140): https://edk2.groups.io/g/devel/message/112140 Mute This Topic: https://groups.io/mt/103021365/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-