summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/TargetTool
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2018-06-25 18:31:26 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-06-27 16:33:21 +0800
commit72443dd25014a8b6209895640af36dec33da51e0 (patch)
treece91675cb7bfadbd4c8686b19d3d816fb968f612 /BaseTools/Source/Python/TargetTool
parent5b0671c1e514e534c6d5be9604da33bfc2cd0a24 (diff)
downloadedk2-72443dd25014a8b6209895640af36dec33da51e0.tar.gz
edk2-72443dd25014a8b6209895640af36dec33da51e0.tar.bz2
edk2-72443dd25014a8b6209895640af36dec33da51e0.zip
BaseTools: Refactor python print statements
Refactor print statements to be compatible with python 3. Based on "futurize -f libfuturize.fixes.fix_print_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/TargetTool')
-rw-r--r--BaseTools/Source/Python/TargetTool/TargetTool.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/Python/TargetTool/TargetTool.py
index 9fb89549cc..0d4a59198e 100644
--- a/BaseTools/Source/Python/TargetTool/TargetTool.py
+++ b/BaseTools/Source/Python/TargetTool/TargetTool.py
@@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import sys
import traceback
@@ -32,7 +33,7 @@ class TargetTool():
self.Arg = args[0]
self.FileName = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 'target.txt'))
if os.path.isfile(self.FileName) == False:
- print "%s does not exist." % self.FileName
+ print("%s does not exist." % self.FileName)
sys.exit(1)
self.TargetTxtDictionary = {
TAB_TAT_DEFINES_ACTIVE_PLATFORM : None,
@@ -83,14 +84,14 @@ class TargetTool():
errMsg = ''
for Key in self.TargetTxtDictionary:
if type(self.TargetTxtDictionary[Key]) == type([]):
- print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key]))
+ print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))
elif self.TargetTxtDictionary[Key] is None:
errMsg += " Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep
else:
- print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])
+ print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))
if errMsg != '':
- print os.linesep + 'Warning:' + os.linesep + errMsg
+ print(os.linesep + 'Warning:' + os.linesep + errMsg)
def RWFile(self, CommentCharacter, KeySplitCharacter, Num):
try:
@@ -109,7 +110,7 @@ class TargetTool():
if Key not in existKeys:
existKeys.append(Key)
else:
- print "Warning: Found duplicate key item in original configuration files!"
+ print("Warning: Found duplicate key item in original configuration files!")
if Num == 0:
Line = "%-30s = \n" % Key
@@ -120,7 +121,7 @@ class TargetTool():
fw.write(Line)
for key in self.TargetTxtDictionary:
if key not in existKeys:
- print "Warning: %s does not exist in original configuration file" % key
+ print("Warning: %s does not exist in original configuration file" % key)
Line = GetConfigureKeyValue(self, key)
if Line is None:
Line = "%-30s = " % key
@@ -223,25 +224,25 @@ if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
if os.getenv('WORKSPACE') is None:
- print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"
+ print("ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool")
sys.exit(1)
(opt, args) = MyOptionParser()
if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):
- print "The number of args isn't 1 or the value of args is invalid."
+ print("The number of args isn't 1 or the value of args is invalid.")
sys.exit(1)
if opt.NUM is not None and opt.NUM < 1:
- print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."
+ print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")
sys.exit(1)
if opt.TARGET is not None and len(opt.TARGET) > 1:
for elem in opt.TARGET:
if elem == '0':
- print "0 will clear the TARGET setting in target.txt and can't combine with other value."
+ print("0 will clear the TARGET setting in target.txt and can't combine with other value.")
sys.exit(1)
if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:
for elem in opt.TARGET_ARCH:
if elem == '0':
- print "0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value."
+ print("0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value.")
sys.exit(1)
try: