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.93; helo=mga11.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 D416021959CB2 for ; Thu, 24 Jan 2019 08:14:25 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2019 08:14:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,517,1539673200"; d="scan'208";a="121005825" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.149]) by orsmga003.jf.intel.com with ESMTP; 24 Jan 2019 08:14:24 -0800 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Thu, 24 Jan 2019 08:14:18 -0800 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [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: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:14:26 -0000 These 2 functions are only used internally. move them to the smallest scope 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/Python/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='', OverrideDir=''): NewFile = GlobalData.gAllFiles[NewFile] return NewFile -def RealPath2(File, Dir='', OverrideDir=''): - NewFile = None - if OverrideDir: - NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))] - if NewFile: - if OverrideDir[-1] == os.path.sep: - return NewFile[len(OverrideDir):], NewFile[0:len(OverrideDir)] - else: - return NewFile[len(OverrideDir) + 1:], NewFile[0:len(OverrideDir)] - if GlobalData.gAllFiles: - NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, File))] - if not NewFile: - NewFile = os.path.normpath(os.path.join(Dir, File)) - if not os.path.exists(NewFile): - return None, None - if NewFile: - if Dir: - if Dir[-1] == 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] = ch.replace(RanStr,'\\\\') return FieldList -def ParseDevPathValue (Value): - if '\\' in Value: - Value.replace('\\', '/').replace(' ', '') - - Cmd = 'DevicePath ' + '"' + Value + '"' - try: - p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - out, err = 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 = len(out.split()) - out = ','.join(out.split()) - return '{' + out + '}', Size - def ParseFieldValue (Value): + def ParseDevPathValue (Value): + if '\\' in Value: + Value.replace('\\', '/').replace(' ', '') + + Cmd = 'DevicePath ' + '"' + Value + '"' + try: + p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + out, err = 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 = len(out.split()) + out = ','.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] def Validate(self, Type='', CaseSensitive=True): + def RealPath2(File, Dir='', OverrideDir=''): + NewFile = None + if OverrideDir: + NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))] + if NewFile: + if OverrideDir[-1] == os.path.sep: + return NewFile[len(OverrideDir):], NewFile[0:len(OverrideDir)] + else: + return NewFile[len(OverrideDir) + 1:], NewFile[0:len(OverrideDir)] + if GlobalData.gAllFiles: + NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, File))] + if not NewFile: + NewFile = os.path.normpath(os.path.join(Dir, File)) + if not os.path.exists(NewFile): + return None, None + if NewFile: + if Dir: + if Dir[-1] == 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 = False if Type and Type.lower() != self.Type: -- 2.16.2.windows.1