From nobody Fri May 17 07:08:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112140+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112140+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1701894438; cv=none; d=zohomail.com; s=zohoarc; b=AyGuowHkGMIe6czI8jNRlHNu8U2OopZLtqir5YO+gT5JeNCHSMsQXWZa8Rcw3V/Ysi7aKOj1VE5ircnroNSQvvdOdZ3lHo/f847L66UOkuBexeIvUBTnV7IWjzQz5Zg1h7Ayc3KW+gABXaUqqJFsbxiluAxsA3W6/RiZllW0KhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701894438; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=3wv04CCldYFGOJDq6FdVR9OpDedqpYo3bw6+ZgTIkw0=; b=UIGqIzgxtRy61WxF3BTKIlKqzJtAZgxnWT0+V5Jmv1QmbrSXqdgDYRiV6hunZXi1RYPmBAiCOCqWf3LrVFcQ1Gocq9Lzn4+LIb3DaOEPDyOCHIrF0PNcBDlFzBtQQvfftckknhf4ujXkrXojtWIkrCf6lgPYIYTYI6bHdEjt8vs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112140+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1701894438457686.1991273299103; Wed, 6 Dec 2023 12:27:18 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=tE9XZZQ3Epj5T1T1lKl6eAsPeY8Zf63ynId5nx8E5WA=; 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=1701894438; v=1; b=FY6IlUcYw81W8tKSlT5R2VuoqMwXjzIuuwBrZDCPJCpj/3ltkKaml0O9aUmcteQYb3GU7oBu xDbjHjcCUc93oEW1OW5oVuUMV8Tq9ek+WoLl/HI7UJ7Mhc0nI/Z8toKRkiRq7sv066/PjxenPCZ 8UuLwExTC+9nYxbUY0fIdO00= X-Received: by 127.0.0.2 with SMTP id 7IYnYY1788612xx26HCDC35I; Wed, 06 Dec 2023 12:27:18 -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: fqcWaJRn8mptBwUARsXEGE5Jx1787277AA= 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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1701894439637100001 Content-Type: text/plain; charset="utf-8" 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/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 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 contains 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] =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.pat= h.join("$(OUTPUT_DIR)", "${s_name}")], ["$(CP) ${src} ${dst}"], []) =20 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: # # 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/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) =20 ## Regular expression for matching macro used in header file inclusion -gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICOD= E) +gMacroPattern =3D re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICO= DE) =20 gIsFileMap =3D {} =20 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 from .UniClassObject import StripComments =20 -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE= | re.UNICODE) +IMAGE_TOKEN =3D re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILIN= E | re.UNICODE) =20 # # Value of different image information block types 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" # # 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, 0x0= 2, 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/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 CHAR_ARRAY_DEFIN =3D 'unsigned char' COMMON_FILE_NAME =3D 'Strings' -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILI= NE | re.UNICODE) +STRING_TOKEN =3D re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTIL= INE | 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/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 =20 ## Regular expression for splitting Dependency Expression string into toke= ns -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/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).' =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.ends= with(')'): 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 TokenSpaceGu= idName in self._Symb: 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 {} =20 # definition for a MACRO name. used to create regular expressions below. -_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 inclusion -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroNamePattern), re= .UNICODE) +gMacroRefPattern =3D re.compile(r"\$\(({})\)".format(_MacroNamePattern), r= e.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/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 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 | re.= 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[' ']+Clas= s") -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]+)[H= h]? +([.\w\$]+) +(\w+)', re.UNICODE) +startPatternGeneral =3D re.compile(r"^Start[' ']+Length[' ']+Name[' ']+Cla= ss") +addressPatternGeneral =3D re.compile(r"^Address[' ']+Publics by Value[' ']= +Rva\+Base") +valuePatternGcc =3D re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]= +)$') +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, varnames): =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*$', firs= tline): + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fir= stline): return _parseForXcodeAndClang9(lines, efifilepath, varnames) if (firstline.startswith("Archive member included ") and firstline.endswith(" file (symbol)")): @@ -96,7 +96,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varnames): 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*Out= \s*In\s*Symbol\s*$', line) \ + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Ou= t\s*In\s*Symbol\s*$', line) \ or line =3D=3D "# Symbols:"): status =3D 1 continue @@ -104,7 +104,7 @@ def _parseForXcodeAndClang9(lines, efifilepath, varname= s): for varname in varnames: if varname in line: # cannot pregenerate this RegEx since it uses varname = 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/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,\ ## # 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/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"} 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-F= 0-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-fA-= 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/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]): 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.txt)= $|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)= $') 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 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 =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*$', firs= tline): + if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', fir= stline): 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_Binar= yPatch_([\w]+))') + valuePattern =3D re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Bina= ryPatch_([\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*Out= \s*In\s*Symbol\s*$', line) \ + if status =3D=3D 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Ou= t\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/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." =20 ## Regular expression for matching Line Control directive like "#line xxx" -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*[{]*$", r= e.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, struct,= 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 criteria= is met: @@ -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 # ## 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 file 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/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 ''' =20 WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 ' LinuxCFLAGS =3D 'CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-variable= ' -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.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 ' + 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 ' else: MakeApp =3D MakeApp + PcdGccMakefile 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)) + \ @@ -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.gG= lobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c")) - MakeApp =3D MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.Out= putPath, PcdValueCommonPath) + MakeApp =3D MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.Ou= tputPath, PcdValueCommonPath) MakeApp =3D MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPat= h) else: PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData.gG= lobalDefines["EDK_TOOLS_PATH"], "Source/C/Common/PcdValueCommon.c")) 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 [] 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, --=20 2.43.0.windows.1 -=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 (#112140): https://edk2.groups.io/g/devel/message/112140 Mute This Topic: https://groups.io/mt/103021365/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-