From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 17E98211B1F87 for ; Mon, 4 Feb 2019 07:38:11 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2019 07:38:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,560,1539673200"; d="scan'208";a="119862184" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga007.fm.intel.com with ESMTP; 04 Feb 2019 07:38:11 -0800 Received: from orsmsx159.amr.corp.intel.com (10.22.240.24) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 4 Feb 2019 07:38:11 -0800 Received: from orsmsx153.amr.corp.intel.com ([169.254.12.50]) by ORSMSX159.amr.corp.intel.com ([169.254.11.106]) with mapi id 14.03.0415.000; Mon, 4 Feb 2019 07:38:10 -0800 From: "Carsey, Jaben" To: "Feng, Bob C" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [edk2] [Patch 1/3] BaseTools: Implement splitquoted function in Build tool Thread-Index: AQHUu4UYf9jwpYg300G+Rk/voCSX7KXPx/FA Date: Mon, 4 Feb 2019 15:38:10 +0000 Message-ID: References: <20190203055515.18336-1-bob.c.feng@intel.com> <20190203055515.18336-2-bob.c.feng@intel.com> In-Reply-To: <20190203055515.18336-2-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGMxMmU2MDQtNGYwZi00ZjhiLWI3ZDAtMDdjNWQzNjk4M2I3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYjVqNVZFMUE0VkdCXC9UeUwrMHJidnJEYjFzQmIzU2xyOUxmSExjWndNWmVOSDdka2FBaVBSY28xTXVKd2dqd0oifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Subject: Re: [Patch 1/3] BaseTools: Implement splitquoted function in Build tool X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2019 15:38:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Code looks good, but I think the function comment is lacking. How about de= scribe the function and what it does instead of saying it replaces distutil= s function (which while correct, didn't really answer my question of "what = is this supposed to do"). > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Feng, Bob C > Sent: Saturday, February 02, 2019 9:55 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [Patch 1/3] BaseTools: Implement splitquoted function in > Build tool >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1509 > On some Linux environment, there may be no distutils.util > library for python3 that will cause build tool crash. > This patch implement distutils.util.split_quoted > in BaseTools so that the build tool will be independent with > distutils.util library. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/Python/AutoGen/UniClassObject.py | 50 > ++++++++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 46 insertions(+), 4 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py > b/BaseTools/Source/Python/AutoGen/UniClassObject.py > index d162387cc5..c4b39d25d4 100644 > --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py > +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py > @@ -16,11 +16,10 @@ > ## > # Import Modules > # > from __future__ import print_function > import Common.LongFilePathOs as os, codecs, re > -import distutils.util > import Common.EdkLogger as EdkLogger > from io import BytesIO > from Common.BuildToolError import * > from Common.StringUtils import GetLineNo > from Common.Misc import PathClass > @@ -41,11 +40,11 @@ NON_BREAKING_CHAR =3D u'\uFFF2' > CR =3D u'\u000D' > LF =3D u'\u000A' > NULL =3D u'\u0000' > TAB =3D u'\t' > BACK_SLASH_PLACEHOLDER =3D u'\u0006' > - > +WHITESPACE =3D ' \t\n\r\v\f' > gIncludePattern =3D re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", > re.MULTILINE | re.UNICODE) >=20 > ## Convert a unicode string to a Hex list > # > # Convert a unicode string to a Hex list > @@ -216,10 +215,54 @@ def StripComments(Line): > CommentPos =3D Line.find (Comment, CommentPos + 1) > else: > return Line[:CommentPos].strip() > return Line.strip() >=20 > +# > +# This function implement distutils.util.split_quoted in another way. > +# > +def splitquoted(s): > + words =3D [] > + word =3D [] > + InQuoted =3D False > + escaped =3D False > + CurrentQ =3D "" > + s =3D s.strip() > + for ch in s: > + if escaped: > + # preserve whatever is escaped; > + # This char will become part of the current word > + word.append(ch) > + escaped =3D False > + continue > + > + if ch in WHITESPACE and not InQuoted: > + # unescaped, unquoted whitespace: now > + # we definitely have a word delimiter > + if "".join(word): > + words.append("".join(word)) > + word =3D [] > + continue > + elif ch =3D=3D "\\": > + escaped =3D True > + if not InQuoted: > + continue > + else: > + # handle singly-quoted string or doubly-quoted string > + if ch =3D=3D'"' or ch =3D=3D "'": > + if not InQuoted: > + InQuoted =3D True > + CurrentQ =3D ch > + continue > + elif ch =3D=3D CurrentQ: > + InQuoted =3D False > + continue > + word.append(ch) > + if word: > + words.append("".join(word)) > + return words > + > ## UniFileClassObject > # > # A structure for .uni file definition > # > class UniFileClassObject(object): > @@ -232,16 +275,15 @@ class UniFileClassObject(object): > self.OrderedStringListByToken =3D {} #{ u'LanguageIdentifie= r' : {Token: > StringDefClassObject} } > self.IsCompatibleMode =3D IsCompatibleMode > self.IncludePathList =3D IncludePathList > if len(self.FileList) > 0: > self.LoadUniFiles(FileList) > - > # > # Get Language definition > # > def GetLangDef(self, File, Line): > - Lang =3D distutils.util.split_quoted((Line.split(u"//")[0])) > + Lang =3D splitquoted((Line.split(u"//")[0])) > if len(Lang) !=3D 3: > try: > FileIn =3D UniFileClassObject.OpenUniFile(LongFilePath(F= ile.Path)) > except UnicodeError as X: > EdkLogger.error("build", FILE_READ_FAILURE, "File read f= ailure: %s" > % str(X), ExtraData=3DFile); > -- > 2.20.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel