diff options
author | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:27:53 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:29:14 +0800 |
commit | 1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch) | |
tree | 0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Source/Python/UPT/Library/Misc.py | |
parent | 678f85131238622e576705117e299d81cff755c9 (diff) | |
download | edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.gz edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.bz2 edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.zip |
Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f85131238622e576705117e299d81cff755c9.
Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/UPT/Library/Misc.py')
-rw-r--r-- | BaseTools/Source/Python/UPT/Library/Misc.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py index f9ca8f32e0..8c2a6787f0 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -32,7 +32,7 @@ from os import linesep from os import walk
from os import environ
import re
-from collections import UserDict as IterableUserDict
+from UserDict import IterableUserDict
import Logger.Log as Logger
from Logger import StringTable as ST
@@ -160,23 +160,19 @@ def RemoveDirectory(Directory, Recursively=False): # or not
#
def SaveFileOnChange(File, Content, IsBinaryFile=True):
+ if not IsBinaryFile:
+ Content = Content.replace("\n", linesep)
+
if os.path.exists(File):
try:
- if isinstance(Content, bytes):
- if Content == __FileHookOpen__(File, "rb").read():
- return False
- else:
- if Content == __FileHookOpen__(File, "r").read():
- return False
+ if Content == __FileHookOpen__(File, "rb").read():
+ return False
except BaseException:
Logger.Error(None, ToolError.FILE_OPEN_FAILURE, ExtraData=File)
CreateDirectory(os.path.dirname(File))
try:
- if isinstance(Content, bytes):
- FileFd = __FileHookOpen__(File, "wb")
- else:
- FileFd = __FileHookOpen__(File, "w")
+ FileFd = __FileHookOpen__(File, "wb")
FileFd.write(Content)
FileFd.close()
except BaseException:
@@ -441,7 +437,7 @@ class Sdict(IterableUserDict): def CommonPath(PathList):
Path1 = min(PathList).split(os.path.sep)
Path2 = max(PathList).split(os.path.sep)
- for Index in range(min(len(Path1), len(Path2))):
+ for Index in xrange(min(len(Path1), len(Path2))):
if Path1[Index] != Path2[Index]:
return os.path.sep.join(Path1[:Index])
return os.path.sep.join(Path1)
@@ -894,7 +890,7 @@ def ProcessEdkComment(LineList): if FindEdkBlockComment:
if FirstPos == -1:
FirstPos = StartPos
- for Index in range(StartPos, EndPos+1):
+ for Index in xrange(StartPos, EndPos+1):
LineList[Index] = ''
FindEdkBlockComment = False
elif Line.find("//") != -1 and not Line.startswith("#"):
@@ -961,7 +957,7 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): FileLinesList = []
try:
- FInputfile = open(FullFileName, "r")
+ FInputfile = open(FullFileName, "rb", 0)
try:
FileLinesList = FInputfile.readlines()
except BaseException:
|