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 B631D941E9C for ; Wed, 20 Dec 2023 22:57:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=rMrmeUtWeeIgXNheLNlvFffaYyYU93OgzRoJoRQJvYQ=; c=relaxed/simple; d=groups.io; h=Feedback-ID:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1703113073; v=1; b=bkKNokK0mIZwK2GvH6KfGkKShJ9isM52DGYxRDI/a5yLBAx2msP4w7t9kFlRq98XLJ3SnEFy ShecaeIA4p+pw02RKbLb1v0ErObpu8B7SCqGKMwMXSPhcQ72p3yzf5dVqg7j7axYlEn5tA43c87 reJ5RgBuA6Kdwa/K0Kn7GB28= X-Received: by 127.0.0.2 with SMTP id 6RPuYY7687511xEUDwnseett; Wed, 20 Dec 2023 14:57:53 -0800 X-Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mx.groups.io with SMTP id smtpd.web10.34894.1703113072506717428 for ; Wed, 20 Dec 2023 14:57:52 -0800 X-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D2D465C074D; Wed, 20 Dec 2023 17:57:51 -0500 (EST) X-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 20 Dec 2023 17:57:51 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddufedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeftvggs vggttggrucevrhgrnhcuoehrvggsvggttggrsegsshguihhordgtohhmqeenucggtffrrg htthgvrhhnpeegheejteffteelieekgfdulefgfffffefgleelhfevkeeuieduhffguedt hfefleenucffohhmrghinheptghomhhpihhlvgdruggrthgrnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhgvsggvtggtrgessghsughiohdr tghomh X-ME-Proxy: Feedback-ID: i5b994698:Fastmail X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Dec 2023 17:57:50 -0500 (EST) Message-ID: <031ca2d6-dd4f-46ef-97ce-13bff796af01@bsdio.com> Date: Wed, 20 Dec 2023 15:57:47 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Resolve regex syntax warnings To: Joey Vagedes , devel@edk2.groups.io Cc: Liming Gao , Bob Feng , Yuwei Chen References: <20231206202703.1568-1-joey.vagedes@gmail.com> <20231206202703.1568-2-joey.vagedes@gmail.com> From: "Rebecca Cran" In-Reply-To: <20231206202703.1568-2-joey.vagedes@gmail.com> 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,rebecca@bsdio.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: PEsfapNKnMhNvlAG6PsxjVFpx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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=bkKNokK0; 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 Thanks. Reviewed-by: Rebecca Cran --=20 Rebecca Cran On 12/6/2023 1:27 PM, Joey Vagedes wrote: > 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/= Python/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 > > import os > > =20 > > -__description__ =3D """ > > +__description__ =3D r""" > > Convert an AML file to a .c file containing the AML bytecode stored in = a C > > array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c. > > Tables\Dsdt.c will contain a C array named "dsdt_aml_code" that contain= s > > diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/S= ource/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] > > =20 > > _PATH_SEP =3D "(+)" > > - _FileTypePattern =3D re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$") > > + _FileTypePattern =3D re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$") > > _BinaryFileRule =3D FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], [os.= path.join("$(OUTPUT_DIR)", "${s_name}")], > > ["$(CP) ${src} ${dst}"], []) > > =20 > > diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Sour= ce/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: > # > > # open and close brace must be taken as individual tokens > > # > > - TokenPattern =3D re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)"= ) > > + TokenPattern =3D re.compile(r"(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)= ") > > =20 > > ## Constructor > > # > > diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Sourc= e/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) > > =20 > > ## Regular expression for matching macro used in header file inclusion > > -gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNIC= ODE) > > +gMacroPattern =3D re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNI= CODE) > > =20 > > gIsFileMap =3D {} > > =20 > > diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTool= s/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 > > from .UniClassObject import StripComments > > =20 > > -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILI= NE | re.UNICODE) > > +IMAGE_TOKEN =3D re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTIL= INE | re.UNICODE) > > =20 > > # > > # Value of different image information block types > > diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools= /Source/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" > # > > # Match name =3D variable > > # > > -gEfiVarStoreNamePattern =3D re.compile("\s*name\s*=3D\s*(\w+)") > > +gEfiVarStoreNamePattern =3D re.compile(r"\s*name\s*=3D\s*(\w+)") > > # > > # The format of guid in efivarstore statement likes following and must = be correct: > > # guid =3D {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, = 0x02, 0x11, 0x3D}} > > # > > -gEfiVarStoreGuidPattern =3D re.compile("\s*guid\s*=3D\s*({.*?{.*?}\s*})"= ) > > +gEfiVarStoreGuidPattern =3D re.compile(r"\s*guid\s*=3D\s*({.*?{.*?}\s*})= ") > > =20 > > # > > # Template string to generic AsBuilt INF > > diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Sou= rce/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 > > CHAR_ARRAY_DEFIN =3D 'unsigned char' > > COMMON_FILE_NAME =3D 'Strings' > > -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTI= LINE | re.UNICODE) > > +STRING_TOKEN =3D re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULT= ILINE | re.UNICODE) > > =20 > > EFI_HII_ARRAY_SIZE_LENGTH =3D 4 > > EFI_HII_PACKAGE_HEADER_LENGTH =3D 4 > > diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTo= ols/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 > > =20 > > ## Regular expression for splitting Dependency Expression string into t= okens > > -gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)") > > +gDepexTokenPattern =3D re.compile(r"(\(|\)|\w+| \S+\.inf)") > > =20 > > ## Regular expression for match: PCD(xxxx.yyy) > > gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$") > > diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sou= rce/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 al= lowed.' > ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAM= ILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' > > =20 > > __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') > > -_ReLabel =3D re.compile('LABEL\((\w+)\)') > > -_ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') > > +_ReLabel =3D re.compile(r'LABEL\((\w+)\)') > > +_ReOffset =3D re.compile(r'OFFSET_OF\((\w+)\)') > > PcdPattern =3D re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-= z_]*$') > > =20 > > ## SplitString > > @@ -242,10 +242,10 @@ class ValueExpression(BaseExpression): > =20 > > =20 > > SymbolPattern =3D re.compile("(" > > - "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\= w+\.\w+|" > > - "&&|\|\||!(?!=3D)|" > > - "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\= W)|(?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|" > > - "(?<=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)" > > + r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|= \w+\.\w+|" > > + r"&&|\|\||!(?!=3D)|" > > + r"(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D= \W)|(?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|" > > + 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)" > > ")") > > =20 > > @staticmethod > > @@ -737,7 +737,7 @@ class ValueExpression(BaseExpression): > self._Token =3D "'" + UStr + "'" > > return self._Token > > elif Expr.startswith('UINT'): > > - Re =3D re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)') > > + Re =3D re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)') > > try: > > RetValue =3D Re.search(Expr).group(1) > > except: > > @@ -975,7 +975,7 @@ class ValueExpressionEx(ValueExpression): > TokenSpaceGuidName =3D '' > > if Item.startswith(TAB_GUID) and Item.e= ndswith(')'): > > try: > > - TokenSpaceGuidName =3D re.search= ('GUID\((\w+)\)', Item).group(1) > > + TokenSpaceGuidName =3D re.search= (r'GUID\((\w+)\)', Item).group(1) > > except: > > pass > > if TokenSpaceGuidName and TokenSpac= eGuidName in self._Symb: > > diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sou= rce/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 {} > > =20 > > # definition for a MACRO name. used to create regular expressions belo= w. > > -_MacroNamePattern =3D "[A-Z][A-Z0-9_]*" > > +_MacroNamePattern =3D r"[A-Z][A-Z0-9_]*" > > =20 > > ## Regular expression for matching macro used in DSC/DEC/INF file inclu= sion > > -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroNamePattern), = re.UNICODE) > > +gMacroRefPattern =3D re.compile(r"\$\(({})\)".format(_MacroNamePattern),= re.UNICODE) > > gMacroDefPattern =3D re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+") > > gMacroNamePattern =3D re.compile("^{}$".format(_MacroNamePattern)) > > =20 > > diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Py= thon/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 > > import struct > > =20 > > -ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") > > +ArrayIndex =3D re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]") > > ## Regular expression used to find out place holders in string template > > -gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | r= e.UNICODE) > > +gPlaceholderPattern =3D re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE | = re.UNICODE) > > =20 > > ## regular expressions for map file processing > > -startPatternGeneral =3D re.compile("^Start[' ']+Length[' ']+Name[' ']+Cl= ass") > > -addressPatternGeneral =3D re.compile("^Address[' ']+Publics by Value[' '= ]+Rva\+Base") > > -valuePatternGcc =3D re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx= ]+)$') > > -pcdPatternGcc =3D re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') > > -secReGeneral =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)= [Hh]? +([.\w\$]+) +(\w+)', re.UNICODE) > > +startPatternGeneral =3D re.compile(r"^Start[' ']+Length[' ']+Name[' ']+C= lass") > > +addressPatternGeneral =3D re.compile(r"^Address[' ']+Publics by Value[' = ']+Rva\+Base") > > +valuePatternGcc =3D re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-F= x]+)$') > > +pcdPatternGcc =3D re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)') > > +secReGeneral =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+= )[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE) > > =20 > > StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') > > =20 > > @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varname= s): > =20 > > if len(lines) =3D=3D 0: return None > > firstline =3D lines[0].strip() > > - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fi= rstline): > > + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', f= irstline): > > return _parseForXcodeAndClang9(lines, efifilepath, varnames) > > if (firstline.startswith("Archive member included ") and > > firstline.endswith(" file (symbol)")): > > @@ -96,7 +96,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varname= s): > ret =3D [] > > for line in lines: > > line =3D line.strip() > > - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*O= ut\s*In\s*Symbol\s*$', line) \ > > + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*= Out\s*In\s*Symbol\s*$', line) \ > > or line =3D=3D "# Symbols:"): > > status =3D 1 > > continue > > @@ -104,7 +104,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varna= mes): > for varname in varnames: > > if varname in line: > > # cannot pregenerate this RegEx since it uses varna= me from varnames. > > - m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' = % varname, line) > > + m =3D re.match(r'^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$'= % varname, line) > > if m is not None: > > ret.append((varname, m.group(1))) > > return ret > > @@ -170,7 +170,7 @@ def _parseGeneral(lines, efifilepath, varnames): > status =3D 0 #0 - beginning of file; 1 - PE section definition; = 2 - symbol table > > secs =3D [] # key =3D section name > > varoffset =3D [] > > - symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$= -]+) +([\da-fA-F]+)', re.UNICODE) > > + symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\= $-]+) +([\da-fA-F]+)', re.UNICODE) > > =20 > > for line in lines: > > line =3D line.strip() > > @@ -1926,4 +1926,4 @@ def CopyDict(ori_dict): > # Remove the c/c++ comments: // and /* */ > > # > > def RemoveCComments(ctext): > > - return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S) > > + return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S) > > diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseT= ools/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_D= EFINES_TOOL_CHAIN_TAG,\ > ## > > # Static variables used for pattern > > # > > -gMacroRefPattern =3D re.compile('(DEF\([^\(\)]+\))') > > -gEnvRefPattern =3D re.compile('(ENV\([^\(\)]+\))') > > -gMacroDefPattern =3D re.compile("DEFINE\s+([^\s]+)") > > +gMacroRefPattern =3D re.compile(r'(DEF\([^\(\)]+\))') > > +gEnvRefPattern =3D re.compile(r'(ENV\([^\(\)]+\))') > > +gMacroDefPattern =3D re.compile(r"DEFINE\s+([^\s]+)") > > gDefaultToolsDefFile =3D "tools_def.txt" > > =20 > > ## ToolDefClassObject > > diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Sour= ce/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"} > > CR_LB_SET =3D {T_CHAR_CR, TAB_LINE_BREAK} > > =20 > > -RegionSizePattern =3D compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\= s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*") > > -RegionSizeGuidPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|= \s*(?P\w+\.\w+[\.\w\[\]]*)\s*") > > -RegionOffsetPcdPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$= ") > > -ShortcutPcdPattern =3D compile("\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA= -F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") > > -BaseAddrValuePattern =3D compile('^0[xX][0-9a-fA-F]+') > > +RegionSizePattern =3D compile(r"\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|= \s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*") > > +RegionSizeGuidPattern =3D compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\= |\s*(?P\w+\.\w+[\.\w\[\]]*)\s*") > > +RegionOffsetPcdPattern =3D compile(r"\s*(?P\w+\.\w+[\.\w\[\]]*)\s*= $") > > +ShortcutPcdPattern =3D compile(r"\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-f= A-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") > > +BaseAddrValuePattern =3D compile(r'^0[xX][0-9a-fA-F]+') > > FileExtensionPattern =3D compile(r'([a-zA-Z][a-zA-Z0-9]*)') > > TokenFindPattern =3D compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-= Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') > > AllIncludeFileList =3D [] > > diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/= Python/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]): > > continue > > MatchDict =3D {} > > - ReFileEnds =3D compile('\S+(.ui)$|\S+(fv.sec.txt= )$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt= )$') > > + ReFileEnds =3D compile(r'\S+(.ui)$|\S+(fv.sec.tx= t)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.tx= t)$') > > FileList =3D os.listdir(FfsPath[0]) > > for File in FileList: > > Match =3D ReFileEnds.search(File) > > 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 Cor= poration. 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 > > =20 > > #=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 > > -symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>= ]+) +([\da-fA-F]+)', re.UNICODE) > > +symRe =3D re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<= >]+) +([\da-fA-F]+)', re.UNICODE) > > =20 > > def parsePcdInfoFromMapFile(mapfilepath, efifilepath): > > """ Parse map file to get binary patch pcd information > > @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): > =20 > > if len(lines) =3D=3D 0: return None > > firstline =3D lines[0].strip() > > - if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fi= rstline): > > + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', f= irstline): > > 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) > > =20 > > def _parseForXcodeAndClang9(lines, efifilepath): > > - valuePattern =3D re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Bin= aryPatch_([\w]+))') > > + valuePattern =3D re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Bi= naryPatch_([\w]+))') > > status =3D 0 > > pcds =3D [] > > for line in lines: > > line =3D line.strip() > > - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*O= ut\s*In\s*Symbol\s*$', line) \ > > + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*= Out\s*In\s*Symbol\s*$', line) \ > > or line =3D=3D "# Symbols:"): > > status =3D 1 > > continue > > @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath): > =20 > > def _parseForGCC(lines, efifilepath): > > """ Parse map file generated by GCC linker """ > > - dataPattern =3D re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$') > > + dataPattern =3D re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$') > > status =3D 0 > > imageBase =3D -1 > > sections =3D [] > > @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath): > status =3D 0 #0 - beginning of file; 1 - PE section definition; = 2 - symbol table > > secs =3D [] # key =3D section name > > bPcds =3D [] > > - symPattern =3D re.compile('^[_]+gPcd_BinaryPatch_([\w]+)') > > + symPattern =3D re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)') > > =20 > > for line in lines: > > line =3D line.strip() > > diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Pyth= on/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 righ= ts reserved." > > =20 > > ## Regular expression for matching Line Control directive like "#line x= xx" > > -gLineControlDirective =3D re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"= ]*)"') > > +gLineControlDirective =3D re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^= "]*)"') > > ## Regular expression for matching "typedef struct" > > -gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", = re.MULTILINE) > > +gTypedefPattern =3D re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$",= re.MULTILINE) > > ## Regular expression for matching "#pragma pack" > > -gPragmaPattern =3D re.compile("^\s*#pragma\s+pack", re.MULTILINE) > > +gPragmaPattern =3D re.compile(r"^\s*#pragma\s+pack", re.MULTILINE) > > ## Regular expression for matching "typedef" > > -gTypedef_SinglePattern =3D re.compile("^\s*typedef", re.MULTILINE) > > +gTypedef_SinglePattern =3D re.compile(r"^\s*typedef", re.MULTILINE) > > ## Regular expression for matching "typedef struct, typedef union, stru= ct, union" > > -gTypedef_MulPattern =3D re.compile("^\s*(typedef)?\s+(struct|union)(\s+\= w+)?\s*[{]*$", re.MULTILINE) > > +gTypedef_MulPattern =3D re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+= \w+)?\s*[{]*$", re.MULTILINE) > > =20 > > # > > # The following number pattern match will only match if following crite= ria is met: > > @@ -44,14 +44,14 @@ gTypedef_MulPattern =3D re.compile("^\s*(typedef)?\s+= (struct|union)(\s+\w+)?\s*[{] > # as the pattern is greedily match, so it is ok for the gDecNumberPatte= rn or gHexNumberPattern to grab the maximum match > > # > > ## Regular expression for matching HEX number > > -gHexNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F= ]+)(U(?=3D$|[^a-zA-Z0-9_]))?") > > +gHexNumberPattern =3D re.compile(r"(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-= F]+)(U(?=3D$|[^a-zA-Z0-9_]))?") > > ## Regular expression for matching decimal number with 'U' postfix > > -gDecNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^= a-zA-Z0-9_])") > > +gDecNumberPattern =3D re.compile(r"(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[= ^a-zA-Z0-9_])") > > ## Regular expression for matching constant with 'ULL' 'LL' postfix > > -gLongNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]= +|[0-9]+)U?LL(?=3D$|[^a-zA-Z0-9_])") > > +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_])") > > =20 > > ## Regular expression for matching "Include ()" in asl file > > -gAslIncludePattern =3D re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\= "\)", re.MULTILINE) > > +gAslIncludePattern =3D re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)= \"\)", re.MULTILINE) > > ## Regular expression for matching C style #include "XXX.asl" in asl fi= le > > gAslCIncludePattern =3D re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]= +)\s*([>"])', re.MULTILINE) > > ## Patterns used to convert EDK conventions to EDK2 ECP conventions > > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTool= s/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 ''' > =20 > > WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 ' > > LinuxCFLAGS =3D 'CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-varia= ble ' > > -PcdMakefileEnd =3D ''' > > +PcdMakefileEnd =3D r''' > > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common > > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app > > ''' > > @@ -110,7 +110,7 @@ LIBS =3D -lCommon > variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') > > SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$') > > ## regular expressions for finding decimal and hex numbers > > -Pattern =3D re.compile('^[1-9]\d*|0$') > > +Pattern =3D re.compile(r'^[1-9]\d*|0$') > > HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$') > > ## Regular expression for finding header file inclusions > > from AutoGen.GenMake import gIncludePattern > > @@ -2840,7 +2840,7 @@ class DscBuildData(PlatformBuildClassObject): > # start generating makefile > > MakeApp =3D PcdMakefileHeader > > if sys.platform =3D=3D "win32": > > - MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Outp= utPath, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJE= CTS =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.j= oin(self.OutputPath, PcdValueCommonName)) + 'INC =3D ' > > + MakeApp =3D MakeApp + r'APPFILE =3D %s\%s.exe\n' % (self.Out= putPath, PcdValueInitName) + r'APPNAME =3D %s\n' % (PcdValueInitName) + r'O= BJECTS =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.pat= h.join(self.OutputPath, PcdValueCommonName)) + 'INC =3D ' > > else: > > MakeApp =3D MakeApp + PcdGccMakefile > > MakeApp =3D MakeApp + 'APPFILE =3D %s/%s\n' % (self.OutputP= ath, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECTS= =3D %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(sel= f.OutputPath, PcdValueCommonName)) + \ > > @@ -2950,7 +2950,7 @@ class DscBuildData(PlatformBuildClassObject): > MakeApp +=3D "$(OBJECTS) : %s\n" % include_file > > if sys.platform =3D=3D "win32": > > PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData= .gGlobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c")) > > - MakeApp =3D MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.O= utputPath, PcdValueCommonPath) > > + MakeApp =3D MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.= OutputPath, PcdValueCommonPath) > > MakeApp =3D MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommon= Path) > > else: > > PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData= .gGlobalDefines["EDK_TOOLS_PATH"], "Source/C/Common/PcdValueCommon.c")) > > diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTo= ols/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 [] > > ArchList =3D set() > > PrivateList =3D set() > > - Line =3D re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine) > > + Line =3D re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine) > > for Item in Line[1:-1].split(TAB_COMMA_SPLIT): > > if Item =3D=3D '': > > EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112774): https://edk2.groups.io/g/devel/message/112774 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-