summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT
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/UPT
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/UPT')
-rw-r--r--BaseTools/Source/Python/UPT/Library/ExpressionValidate.py3
-rw-r--r--BaseTools/Source/Python/UPT/Library/UniClassObject.py9
-rw-r--r--BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py51
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py5
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py9
5 files changed, 41 insertions, 36 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
index ca21e69952..afa5b2407e 100644
--- a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
+++ b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
@@ -14,6 +14,7 @@
'''
ExpressionValidate
'''
+from __future__ import print_function
##
# Import Modules
@@ -566,7 +567,7 @@ def IsValidFeatureFlagExp(Token, Flag=False):
if __name__ == '__main__':
# print IsValidRangeExpr('LT 9')
- print _LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression()
+ print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression())
diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index 299cd87144..a464cbf702 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -14,6 +14,7 @@
"""
Collect all defined strings in multiple uni files
"""
+from __future__ import print_function
##
# Import Modules
@@ -730,7 +731,7 @@ class UniFileClassObject(object):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
NewLines.append(Line)
else:
- print Line
+ print(Line)
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
if StrName and not StrName.split()[1].startswith(u'STR_'):
@@ -1022,12 +1023,12 @@ class UniFileClassObject(object):
# Show the instance itself
#
def ShowMe(self):
- print self.LanguageDef
+ print(self.LanguageDef)
#print self.OrderedStringList
for Item in self.OrderedStringList:
- print Item
+ print(Item)
for Member in self.OrderedStringList[Item]:
- print str(Member)
+ print(str(Member))
#
# Read content from '!include' UNI file
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
index 436dc90e6d..074aa311f3 100644
--- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
+++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
@@ -15,6 +15,7 @@
'''
DecPomAlignment
'''
+from __future__ import print_function
##
# Import Modules
@@ -902,47 +903,47 @@ class DecPomAlignment(PackageObject):
# Print all members and their values of Package class
#
def ShowPackage(self):
- print '\nName =', self.GetName()
- print '\nBaseName =', self.GetBaseName()
- print '\nVersion =', self.GetVersion()
- print '\nGuid =', self.GetGuid()
+ print('\nName =', self.GetName())
+ print('\nBaseName =', self.GetBaseName())
+ print('\nVersion =', self.GetVersion())
+ print('\nGuid =', self.GetGuid())
- print '\nStandardIncludes = %d ' \
- % len(self.GetStandardIncludeFileList()),
+ print('\nStandardIncludes = %d ' \
+ % len(self.GetStandardIncludeFileList()), end=' ')
for Item in self.GetStandardIncludeFileList():
- print Item.GetFilePath(), ' ', Item.GetSupArchList()
- print '\nPackageIncludes = %d \n' \
- % len(self.GetPackageIncludeFileList()),
+ print(Item.GetFilePath(), ' ', Item.GetSupArchList())
+ print('\nPackageIncludes = %d \n' \
+ % len(self.GetPackageIncludeFileList()), end=' ')
for Item in self.GetPackageIncludeFileList():
- print Item.GetFilePath(), ' ', Item.GetSupArchList()
+ print(Item.GetFilePath(), ' ', Item.GetSupArchList())
- print '\nGuids =', self.GetGuidList()
+ print('\nGuids =', self.GetGuidList())
for Item in self.GetGuidList():
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
- print '\nProtocols =', self.GetProtocolList()
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+ print('\nProtocols =', self.GetProtocolList())
for Item in self.GetProtocolList():
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
- print '\nPpis =', self.GetPpiList()
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+ print('\nPpis =', self.GetPpiList())
for Item in self.GetPpiList():
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
- print '\nLibraryClasses =', self.GetLibraryClassList()
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+ print('\nLibraryClasses =', self.GetLibraryClassList())
for Item in self.GetLibraryClassList():
- print Item.GetLibraryClass(), Item.GetRecommendedInstance(), \
- Item.GetSupArchList()
- print '\nPcds =', self.GetPcdList()
+ print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \
+ Item.GetSupArchList())
+ print('\nPcds =', self.GetPcdList())
for Item in self.GetPcdList():
- print 'CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \
+ print('CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \
Item.GetTokenSpaceGuidCName(), \
'DefaultValue=', Item.GetDefaultValue(), \
'ValidUsage=', Item.GetValidUsage(), \
'SupArchList', Item.GetSupArchList(), \
- 'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType()
+ 'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType())
for Item in self.GetMiscFileList():
- print Item.GetName()
+ print(Item.GetName())
for FileObjectItem in Item.GetFileList():
- print FileObjectItem.GetURI()
- print '****************\n'
+ print(FileObjectItem.GetURI())
+ print('****************\n')
## GenPcdDeclaration
#
diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
index 8b4ece2617..5f0abcafef 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
@@ -11,6 +11,7 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+from __future__ import print_function
import os
import unittest
@@ -66,7 +67,7 @@ def TestTemplate(TestString, TestFunc):
# Close file
f.close()
except:
- print 'Can not create temporary file [%s]!' % Path
+ print('Can not create temporary file [%s]!' % Path)
exit(-1)
# Call test function to test
@@ -279,6 +280,6 @@ if __name__ == '__main__':
unittest.FunctionTestCase(TestDecPcd).runTest()
unittest.FunctionTestCase(TestDecUserExtension).runTest()
- print 'All tests passed...'
+ print('All tests passed...')
diff --git a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
index f3b43ee0bc..626f17426d 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
@@ -11,6 +11,7 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+from __future__ import print_function
import os
#import Object.Parser.InfObject as InfObject
from Object.Parser.InfCommonObject import CurrentLine
@@ -271,7 +272,7 @@ def PrepareTest(String):
TempFile = open (FileName, "w")
TempFile.close()
except:
- print "File Create Error"
+ print("File Create Error")
CurrentLine = CurrentLine()
CurrentLine.SetFileName("Test")
CurrentLine.SetLineString(Item[0])
@@ -376,11 +377,11 @@ if __name__ == '__main__':
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
- print "Test Failed!"
+ print("Test Failed!")
AllPassedFlag = False
if AllPassedFlag :
- print 'All tests passed...'
+ print('All tests passed...')
else:
- print 'Some unit test failed!'
+ print('Some unit test failed!')