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.88; helo=mga01.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 B52C6211A6D56 for ; Sun, 27 Jan 2019 19:45:49 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jan 2019 19:45:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,532,1539673200"; d="scan'208";a="119955686" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga008.fm.intel.com with ESMTP; 27 Jan 2019 19:45:49 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 27 Jan 2019 19:45:49 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.36]) with mapi id 14.03.0415.000; Mon, 28 Jan 2019 11:45:46 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [Patch v1 1/4] BaseTools/Common/Misc: move private functions Thread-Index: AQHUs//m7ty7TenE/0+z0eWd5RcnpaXED+IA Date: Mon, 28 Jan 2019 03:45:45 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D160076149@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v1 1/4] BaseTools/Common/Misc: move private functions 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, 28 Jan 2019 03:45:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, January 25, 2019 12:14 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Gao, Liming Subject: [Patch v1 1/4] BaseTools/Common/Misc: move private functions These 2 functions are only used internally. move them to the smallest scop= e and use them. Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Misc.py | 92 ++++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 8e4217a4f6e5..c547c2f8e43a 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -566,32 +566,6 @@ def RealPath(File, Dir=3D'', OverrideDir=3D''): NewFile =3D GlobalData.gAllFiles[NewFile] return NewFile =20 -def RealPath2(File, Dir=3D'', OverrideDir=3D''): - NewFile =3D None - if OverrideDir: - NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.join(Ove= rrideDir, File))] - if NewFile: - if OverrideDir[-1] =3D=3D os.path.sep: - return NewFile[len(OverrideDir):], NewFile[0:len(OverrideD= ir)] - else: - return NewFile[len(OverrideDir) + 1:], NewFile[0:len(Overr= ideDir)] - if GlobalData.gAllFiles: - NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir= , File))] - if not NewFile: - NewFile =3D os.path.normpath(os.path.join(Dir, File)) - if not os.path.exists(NewFile): - return None, None - if NewFile: - if Dir: - if Dir[-1] =3D=3D os.path.sep: - return NewFile[len(Dir):], NewFile[0:len(Dir)] - else: - return NewFile[len(Dir) + 1:], NewFile[0:len(Dir)] - else: - return NewFile, '' - - return None, None - ## Get GUID value from given packages # # @param CName The CName of the GUID @@ -1189,27 +1163,27 @@ def AnalyzePcdExpression(Setting): FieldList[i] =3D ch.replace(RanStr,'\\\\') return FieldList =20 -def ParseDevPathValue (Value): - if '\\' in Value: - Value.replace('\\', '/').replace(' ', '') - - Cmd =3D 'DevicePath ' + '"' + Value + '"' - try: - p =3D subprocess.Popen(Cmd, stdout=3Dsubprocess.PIPE, stderr=3Dsub= process.PIPE, shell=3DTrue) - out, err =3D p.communicate() - except Exception as X: - raise BadExpression("DevicePath: %s" % (str(X)) ) - finally: - subprocess._cleanup() - p.stdout.close() - p.stderr.close() - if err: - raise BadExpression("DevicePath: %s" % str(err)) - Size =3D len(out.split()) - out =3D ','.join(out.split()) - return '{' + out + '}', Size - def ParseFieldValue (Value): + def ParseDevPathValue (Value): + if '\\' in Value: + Value.replace('\\', '/').replace(' ', '') + + Cmd =3D 'DevicePath ' + '"' + Value + '"' + try: + p =3D subprocess.Popen(Cmd, stdout=3Dsubprocess.PIPE, stderr= =3Dsubprocess.PIPE, shell=3DTrue) + out, err =3D p.communicate() + except Exception as X: + raise BadExpression("DevicePath: %s" % (str(X)) ) + finally: + subprocess._cleanup() + p.stdout.close() + p.stderr.close() + if err: + raise BadExpression("DevicePath: %s" % str(err)) + Size =3D len(out.split()) + out =3D ','.join(out.split()) + return '{' + out + '}', Size + if "{CODE(" in Value: return Value, len(Value.split(",")) if isinstance(Value, type(0)): @@ -1625,6 +1599,32 @@ class PathClass(object): return os.stat(self.Path)[8] =20 def Validate(self, Type=3D'', CaseSensitive=3DTrue): + def RealPath2(File, Dir=3D'', OverrideDir=3D''): + NewFile =3D None + if OverrideDir: + NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.= join(OverrideDir, File))] + if NewFile: + if OverrideDir[-1] =3D=3D os.path.sep: + return NewFile[len(OverrideDir):], NewFile[0:len(O= verrideDir)] + else: + return NewFile[len(OverrideDir) + 1:], NewFile[0:l= en(OverrideDir)] + if GlobalData.gAllFiles: + NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.= join(Dir, File))] + if not NewFile: + NewFile =3D os.path.normpath(os.path.join(Dir, File)) + if not os.path.exists(NewFile): + return None, None + if NewFile: + if Dir: + if Dir[-1] =3D=3D os.path.sep: + return NewFile[len(Dir):], NewFile[0:len(Dir)] + else: + return NewFile[len(Dir) + 1:], NewFile[0:len(Dir)] + else: + return NewFile, '' + + return None, None + if GlobalData.gCaseInsensitive: CaseSensitive =3D False if Type and Type.lower() !=3D self.Type: -- 2.16.2.windows.1