From: "Feng, Bob C" <bob.c.feng@intel.com>
To: "Carsey, Jaben" <jaben.carsey@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>
Subject: Re: [Patch v1 1/4] BaseTools/Common/Misc: move private functions
Date: Mon, 28 Jan 2019 03:45:45 +0000 [thread overview]
Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D160076149@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <f18e720e467ac80efffa014265369a83776e86cb.1548270790.git.jaben.carsey@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Carsey, Jaben
Sent: Friday, January 25, 2019 12:14 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [Patch v1 1/4] BaseTools/Common/Misc: move private functions
These 2 functions are only used internally. move them to the smallest scope and use them.
Cc: Bob Feng <Bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
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
next prev parent reply other threads:[~2019-01-28 3:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 16:14 [Patch v1 0/4] Cleanup the Common.misc file Jaben Carsey
2019-01-24 16:14 ` [Patch v1 1/4] BaseTools/Common/Misc: move private functions Jaben Carsey
2019-01-28 3:45 ` Feng, Bob C [this message]
2019-01-24 16:14 ` [Patch v1 2/4] BaseTools/Common/Misc: remove uncalled code Jaben Carsey
2019-01-28 3:45 ` Feng, Bob C
2019-01-24 16:14 ` [Patch v1 3/4] BaseTools/Common/Misc: Cleanup the imports Jaben Carsey
2019-01-28 3:45 ` Feng, Bob C
2019-01-24 16:14 ` [Patch v1 4/4] BaseTools/build/build: delete variable Jaben Carsey
2019-01-28 3:45 ` Feng, Bob C
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08650203BA1BD64D8AD9B6D5D74A85D160076149@SHSMSX101.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox