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>
---
BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py | 3 +-
BaseTools/Scripts/BinToPcd.py | 37 +++---
BaseTools/Scripts/MemoryProfileSymbolGen.py | 14 +--
BaseTools/Scripts/SmiHandlerProfileSymbolGen.py | 20 +--
BaseTools/Source/Python/AutoGen/AutoGen.py | 5 +-
BaseTools/Source/Python/AutoGen/BuildEngine.py | 31 ++---
BaseTools/Source/Python/AutoGen/UniClassObject.py | 7 +-
BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py | 5 +-
BaseTools/Source/Python/BPDG/BPDG.py | 3 +-
BaseTools/Source/Python/Common/DecClassObject.py | 39 +++---
BaseTools/Source/Python/Common/Dictionary.py | 7 +-
BaseTools/Source/Python/Common/DscClassObject.py | 67 +++++-----
BaseTools/Source/Python/Common/EdkIIWorkspace.py | 23 ++--
BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py | 133 ++++++++++----------
BaseTools/Source/Python/Common/Expression.py | 11 +-
BaseTools/Source/Python/Common/FdfParserLite.py | 29 ++---
BaseTools/Source/Python/Common/InfClassObject.py | 113 ++++++++---------
BaseTools/Source/Python/Common/RangeExpression.py | 5 +-
BaseTools/Source/Python/Common/TargetTxtClassObject.py | 13 +-
BaseTools/Source/Python/Common/VpdInfoFile.py | 3 +-
BaseTools/Source/Python/Ecc/CParser.py | 3 +-
BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 69 +++++-----
BaseTools/Source/Python/Ecc/Configuration.py | 5 +-
BaseTools/Source/Python/Ecc/Exception.py | 3 +-
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py | 3 +-
BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py | 5 +-
BaseTools/Source/Python/Ecc/c.py | 13 +-
BaseTools/Source/Python/Eot/CParser.py | 3 +-
BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 61 ++++-----
BaseTools/Source/Python/Eot/FvImage.py | 13 +-
BaseTools/Source/Python/Eot/InfParserLite.py | 7 +-
BaseTools/Source/Python/Eot/c.py | 3 +-
BaseTools/Source/Python/GenFds/FdfParser.py | 7 +-
BaseTools/Source/Python/GenFds/GenFds.py | 3 +-
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 +-
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 7 +-
BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 23 ++--
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 15 +--
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 17 +--
BaseTools/Source/Python/TargetTool/TargetTool.py | 23 ++--
BaseTools/Source/Python/UPT/Library/ExpressionValidate.py | 3 +-
BaseTools/Source/Python/UPT/Library/UniClassObject.py | 9 +-
BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py | 51 ++++----
BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py | 5 +-
BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py | 9 +-
BaseTools/Source/Python/Workspace/DscBuildData.py | 19 +--
BaseTools/Source/Python/Workspace/MetaFileParser.py | 3 +-
BaseTools/Source/Python/build/build.py | 3 +-
BaseTools/Tests/TestTools.py | 5 +-
BaseTools/Tests/TianoCompress.py | 5 +-
BaseTools/gcc/mingw-gcc-build.py | 99 +++++++--------
51 files changed, 557 insertions(+), 508 deletions(-)
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
index 69fd2d54413e..dd66c7111ac0 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
@@ -23,6 +23,7 @@
#
# ExceptionList if a tool takes an argument with a / add it to the exception list
#
+from __future__ import print_function
import sys
import os
import subprocess
@@ -86,7 +87,7 @@ if __name__ == "__main__":
ret = main(sys.argv[2:])
except:
- print "exiting: exception from " + sys.argv[0]
+ print("exiting: exception from " + sys.argv[0])
ret = 2
sys.exit(ret)
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index 68a7ac652d70..c4e7b8a5c2e2 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -14,6 +14,7 @@
'''
BinToPcd
'''
+from __future__ import print_function
import sys
import argparse
@@ -98,7 +99,7 @@ if __name__ == '__main__':
Buffer = args.InputFile.read()
args.InputFile.close()
except:
- print 'BinToPcd: error: can not read binary input file'
+ print('BinToPcd: error: can not read binary input file')
sys.exit()
#
@@ -109,7 +110,7 @@ if __name__ == '__main__':
# If PcdName is None, then only a PCD value is being requested.
Pcd = ByteArray (Buffer)
if args.Verbose:
- print 'PcdToBin: Convert binary file to PCD Value'
+ print('PcdToBin: Convert binary file to PCD Value')
elif args.PcdType is None:
#
# If --type is neither VPD nor HII, then use PCD statement syntax that is
@@ -123,18 +124,18 @@ if __name__ == '__main__':
#
Pcd = ' %s|%s' % (args.PcdName, ByteArray (Buffer))
elif args.MaxSize < len(Buffer):
- print 'BinToPcd: error: argument --max-size is smaller than input file.'
+ print('BinToPcd: error: argument --max-size is smaller than input file.')
sys.exit()
else:
Pcd = ' %s|%s|VOID*|%d' % (args.PcdName, ByteArray (Buffer), args.MaxSize)
args.MaxSize = len(Buffer)
if args.Verbose:
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections:'
- print ' [PcdsFixedAtBuild]'
- print ' [PcdsPatchableInModule]'
- print ' [PcdsDynamicDefault]'
- print ' [PcdsDynamicExDefault]'
+ print('PcdToBin: Convert binary file to PCD statement compatible with PCD sections:')
+ print(' [PcdsFixedAtBuild]')
+ print(' [PcdsPatchableInModule]')
+ print(' [PcdsDynamicDefault]')
+ print(' [PcdsDynamicExDefault]')
elif args.PcdType == 'VPD':
if args.MaxSize is None:
#
@@ -143,7 +144,7 @@ if __name__ == '__main__':
#
args.MaxSize = len(Buffer)
if args.MaxSize < len(Buffer):
- print 'BinToPcd: error: argument --max-size is smaller than input file.'
+ print('BinToPcd: error: argument --max-size is smaller than input file.')
sys.exit()
if args.Offset is None:
#
@@ -157,15 +158,15 @@ if __name__ == '__main__':
#
Pcd = ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, ByteArray (Buffer))
if args.Verbose:
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections'
- print ' [PcdsDynamicVpd]'
- print ' [PcdsDynamicExVpd]'
+ print('PcdToBin: Convert binary file to PCD statement compatible with PCD sections')
+ print(' [PcdsDynamicVpd]')
+ print(' [PcdsDynamicExVpd]')
elif args.PcdType == 'HII':
if args.VariableGuid is None:
- print 'BinToPcd: error: argument --variable-guid is required for --type HII.'
+ print('BinToPcd: error: argument --variable-guid is required for --type HII.')
sys.exit()
if args.VariableName is None:
- print 'BinToPcd: error: argument --variable-name is required for --type HII.'
+ print('BinToPcd: error: argument --variable-name is required for --type HII.')
sys.exit()
if args.Offset is None:
#
@@ -174,9 +175,9 @@ if __name__ == '__main__':
args.Offset = 0
Pcd = ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args.VariableGuid, args.Offset, ByteArray (Buffer))
if args.Verbose:
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections'
- print ' [PcdsDynamicHii]'
- print ' [PcdsDynamicExHii]'
+ print('PcdToBin: Convert binary file to PCD statement compatible with PCD sections')
+ print(' [PcdsDynamicHii]')
+ print(' [PcdsDynamicExHii]')
#
# Write PCD value or PCD statement to the output file
@@ -189,4 +190,4 @@ if __name__ == '__main__':
# If output file is not specified or it can not be written, then write the
# PCD value or PCD statement to the console
#
- print Pcd
+ print(Pcd)
diff --git a/BaseTools/Scripts/MemoryProfileSymbolGen.py b/BaseTools/Scripts/MemoryProfileSymbolGen.py
index 5709ad4641cb..3bc6a8897bcc 100644
--- a/BaseTools/Scripts/MemoryProfileSymbolGen.py
+++ b/BaseTools/Scripts/MemoryProfileSymbolGen.py
@@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
-
+from __future__ import print_function
import os
import re
import sys
@@ -58,10 +58,10 @@ class Symbols:
try:
nmCommand = "nm"
nmLineOption = "-l"
- print "parsing (debug) - " + pdbName
+ print("parsing (debug) - " + pdbName)
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))
except :
- print 'ERROR: nm command not available. Please verify PATH'
+ print('ERROR: nm command not available. Please verify PATH')
return
#
@@ -111,11 +111,11 @@ class Symbols:
DIA2DumpCommand = "Dia2Dump.exe"
#DIA2SymbolOption = "-p"
DIA2LinesOption = "-l"
- print "parsing (pdb) - " + pdbName
+ print("parsing (pdb) - " + pdbName)
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))
except :
- print 'ERROR: DIA2Dump command not available. Please verify PATH'
+ print('ERROR: DIA2Dump command not available. Please verify PATH')
return
#
@@ -254,12 +254,12 @@ def main():
try :
file = open(Options.inputfilename)
except Exception:
- print "fail to open " + Options.inputfilename
+ print("fail to open " + Options.inputfilename)
return 1
try :
newfile = open(Options.outputfilename, "w")
except Exception:
- print "fail to open " + Options.outputfilename
+ print("fail to open " + Options.outputfilename)
return 1
try:
diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
index f03278b64f8f..d0963a17e870 100644
--- a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
+++ b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
@@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
-
+from __future__ import print_function
import os
import re
import sys
@@ -61,10 +61,10 @@ class Symbols:
try:
nmCommand = "nm"
nmLineOption = "-l"
- print "parsing (debug) - " + pdbName
+ print("parsing (debug) - " + pdbName)
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))
except :
- print 'ERROR: nm command not available. Please verify PATH'
+ print('ERROR: nm command not available. Please verify PATH')
return
#
@@ -103,11 +103,11 @@ class Symbols:
DIA2DumpCommand = "Dia2Dump.exe"
#DIA2SymbolOption = "-p"
DIA2LinesOption = "-l"
- print "parsing (pdb) - " + pdbName
+ print("parsing (pdb) - " + pdbName)
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))
except :
- print 'ERROR: DIA2Dump command not available. Please verify PATH'
+ print('ERROR: DIA2Dump command not available. Please verify PATH')
return
#
@@ -235,14 +235,14 @@ def main():
try :
DOMTree = xml.dom.minidom.parse(Options.inputfilename)
except Exception:
- print "fail to open input " + Options.inputfilename
+ print("fail to open input " + Options.inputfilename)
return 1
if Options.guidreffilename is not None:
try :
guidreffile = open(Options.guidreffilename)
except Exception:
- print "fail to open guidref" + Options.guidreffilename
+ print("fail to open guidref" + Options.guidreffilename)
return 1
genGuidString(guidreffile)
guidreffile.close()
@@ -277,7 +277,7 @@ def main():
Handler = smiHandler.getElementsByTagName("Handler")
RVA = Handler[0].getElementsByTagName("RVA")
- print " Handler RVA: %s" % RVA[0].childNodes[0].data
+ print(" Handler RVA: %s" % RVA[0].childNodes[0].data)
if (len(RVA)) >= 1:
rvaName = RVA[0].childNodes[0].data
@@ -289,7 +289,7 @@ def main():
Caller = smiHandler.getElementsByTagName("Caller")
RVA = Caller[0].getElementsByTagName("RVA")
- print " Caller RVA: %s" % RVA[0].childNodes[0].data
+ print(" Caller RVA: %s" % RVA[0].childNodes[0].data)
if (len(RVA)) >= 1:
rvaName = RVA[0].childNodes[0].data
@@ -302,7 +302,7 @@ def main():
try :
newfile = open(Options.outputfilename, "w")
except Exception:
- print "fail to open output" + Options.outputfilename
+ print("fail to open output" + Options.outputfilename)
return 1
newfile.write(DOMTree.toprettyxml(indent = "\t", newl = "\n", encoding = "utf-8"))
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index faec5506a0e6..5e55d5d655e3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -13,6 +13,7 @@
## Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import os.path as path
@@ -757,7 +758,7 @@ class WorkspaceAutoGen(AutoGen):
os.makedirs(self.BuildDir)
with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:
for f in AllWorkSpaceMetaFiles:
- print >> file, f
+ print(f, file=file)
return True
def _GenPkgLevelHash(self, Pkg):
@@ -4631,7 +4632,7 @@ class ModuleAutoGen(AutoGen):
os.remove (self.GetTimeStampPath())
with open(self.GetTimeStampPath(), 'w+') as file:
for f in FileSet:
- print >> file, f
+ print(f, file=file)
Module = property(_GetModule)
Name = property(_GetBaseName)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 63ed47d94bcb..46685967d1ee 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import copy
@@ -625,19 +626,19 @@ if __name__ == '__main__':
EdkLogger.Initialize()
if len(sys.argv) > 1:
Br = BuildRule(sys.argv[1])
- print str(Br[".c", "DXE_DRIVER", "IA32", "MSFT"][1])
- print
- print str(Br[".c", "DXE_DRIVER", "IA32", "INTEL"][1])
- print
- print str(Br[".c", "DXE_DRIVER", "IA32", "GCC"][1])
- print
- print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
- print
- print str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1])
- print
- print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
- print
- print str(Br[".s", "SEC", "IPF", "COMMON"][1])
- print
- print str(Br[".s", "SEC"][1])
+ print(str(Br[".c", "DXE_DRIVER", "IA32", "MSFT"][1]))
+ print()
+ print(str(Br[".c", "DXE_DRIVER", "IA32", "INTEL"][1]))
+ print()
+ print(str(Br[".c", "DXE_DRIVER", "IA32", "GCC"][1]))
+ print()
+ print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+ print()
+ print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1]))
+ print()
+ print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+ print()
+ print(str(Br[".s", "SEC", "IPF", "COMMON"][1]))
+ print()
+ print(str(Br[".s", "SEC"][1]))
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 2711fc104f52..264cf1546566 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -16,6 +16,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os, codecs, re
import distutils.util
import Common.EdkLogger as EdkLogger
@@ -684,12 +685,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))
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index 92ede7a82324..53da9b881f25 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -14,6 +14,7 @@
# #
# Import Modules
#
+from __future__ import print_function
import os
from Common.RangeExpression import RangeExpression
from Common.Misc import *
@@ -345,6 +346,6 @@ if __name__ == "__main__":
test2 = TestObj(2)
testarr = [test1, test2]
- print TestObj(2) in testarr
- print TestObj(2) == test2
+ print(TestObj(2) in testarr)
+ print(TestObj(2) == test2)
diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py
index b1e328ff3f11..9ab13a39e8bf 100644
--- a/BaseTools/Source/Python/BPDG/BPDG.py
+++ b/BaseTools/Source/Python/BPDG/BPDG.py
@@ -20,6 +20,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import sys
import encodings.ascii
@@ -132,7 +133,7 @@ def MyOptionParser():
#
def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):
if os.path.exists(VpdFileName) and not Force:
- print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName
+ print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName)
choice = sys.stdin.readline()
if choice.strip().lower() not in ['y', 'yes', '']:
return
diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py
index d7c70a7336a0..970e644318d0 100644
--- a/BaseTools/Source/Python/Common/DecClassObject.py
+++ b/BaseTools/Source/Python/Common/DecClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
from String import *
from DataType import *
@@ -517,31 +518,31 @@ class Dec(DecObject):
def ShowPackage(self):
M = self.Package
for Arch in M.Header.keys():
- print '\nArch =', Arch
- print 'Filename =', M.Header[Arch].FileName
- print 'FullPath =', M.Header[Arch].FullPath
- print 'BaseName =', M.Header[Arch].Name
- print 'Guid =', M.Header[Arch].Guid
- print 'Version =', M.Header[Arch].Version
- print 'DecSpecification =', M.Header[Arch].DecSpecification
- print '\nIncludes =', M.Includes
+ print('\nArch =', Arch)
+ print('Filename =', M.Header[Arch].FileName)
+ print('FullPath =', M.Header[Arch].FullPath)
+ print('BaseName =', M.Header[Arch].Name)
+ print('Guid =', M.Header[Arch].Guid)
+ print('Version =', M.Header[Arch].Version)
+ print('DecSpecification =', M.Header[Arch].DecSpecification)
+ print('\nIncludes =', M.Includes)
for Item in M.Includes:
- print Item.FilePath, Item.SupArchList
- print '\nGuids =', M.GuidDeclarations
+ print(Item.FilePath, Item.SupArchList)
+ print('\nGuids =', M.GuidDeclarations)
for Item in M.GuidDeclarations:
- print Item.CName, Item.Guid, Item.SupArchList
- print '\nProtocols =', M.ProtocolDeclarations
+ print(Item.CName, Item.Guid, Item.SupArchList)
+ print('\nProtocols =', M.ProtocolDeclarations)
for Item in M.ProtocolDeclarations:
- print Item.CName, Item.Guid, Item.SupArchList
- print '\nPpis =', M.PpiDeclarations
+ print(Item.CName, Item.Guid, Item.SupArchList)
+ print('\nPpis =', M.PpiDeclarations)
for Item in M.PpiDeclarations:
- print Item.CName, Item.Guid, Item.SupArchList
- print '\nLibraryClasses =', M.LibraryClassDeclarations
+ print(Item.CName, Item.Guid, Item.SupArchList)
+ print('\nLibraryClasses =', M.LibraryClassDeclarations)
for Item in M.LibraryClassDeclarations:
- print Item.LibraryClass, Item.RecommendedInstance, Item.SupModuleList, Item.SupArchList
- print '\nPcds =', M.PcdDeclarations
+ print(Item.LibraryClass, Item.RecommendedInstance, Item.SupModuleList, Item.SupArchList)
+ print('\nPcds =', M.PcdDeclarations)
for Item in M.PcdDeclarations:
- print 'CName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, 'Token=', Item.Token, 'DatumType=', Item.DatumType, Item.SupArchList
+ print('CName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, 'Token=', Item.Token, 'DatumType=', Item.DatumType, Item.SupArchList)
##
#
diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py
index 1c33fefabf98..5f2cc8f31ffa 100644
--- a/BaseTools/Source/Python/Common/Dictionary.py
+++ b/BaseTools/Source/Python/Common/Dictionary.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import EdkLogger
from DataType import *
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -58,7 +59,7 @@ def printDict(Dict):
KeyList = Dict.keys()
for Key in KeyList:
if Dict[Key] != '':
- print Key + ' = ' + str(Dict[Key])
+ print(Key + ' = ' + str(Dict[Key]))
## Print the dictionary
#
@@ -71,6 +72,6 @@ def printList(Key, List):
if type(List) == type([]):
if len(List) > 0:
if Key.find(TAB_SPLIT) != -1:
- print "\n" + Key
+ print("\n" + Key)
for Item in List:
- print Item
+ print(Item)
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py
index c2fa1c275a2d..3a27fbffc934 100644
--- a/BaseTools/Source/Python/Common/DscClassObject.py
+++ b/BaseTools/Source/Python/Common/DscClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import EdkLogger as EdkLogger
import Database
@@ -1365,7 +1366,7 @@ class Dsc(DscObject):
# Print all members and their values of Dsc class
#
def ShowDsc(self):
- print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END
+ print(TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END)
printDict(self.Defines.DefinesDictionary)
for Key in self.KeyList:
@@ -1382,47 +1383,47 @@ class Dsc(DscObject):
def ShowPlatform(self):
M = self.Platform
for Arch in M.Header.keys():
- print '\nArch =', Arch
- print 'Filename =', M.Header[Arch].FileName
- print 'FullPath =', M.Header[Arch].FullPath
- print 'BaseName =', M.Header[Arch].Name
- print 'Guid =', M.Header[Arch].Guid
- print 'Version =', M.Header[Arch].Version
- print 'DscSpecification =', M.Header[Arch].DscSpecification
- print 'SkuId =', M.Header[Arch].SkuIdName
- print 'SupArchList =', M.Header[Arch].SupArchList
- print 'BuildTargets =', M.Header[Arch].BuildTargets
- print 'OutputDirectory =', M.Header[Arch].OutputDirectory
- print 'BuildNumber =', M.Header[Arch].BuildNumber
- print 'MakefileName =', M.Header[Arch].MakefileName
- print 'BsBaseAddress =', M.Header[Arch].BsBaseAddress
- print 'RtBaseAddress =', M.Header[Arch].RtBaseAddress
- print 'Define =', M.Header[Arch].Define
- print 'Fdf =', M.FlashDefinitionFile.FilePath
- print '\nBuildOptions =', M.BuildOptions, M.BuildOptions.IncludeFiles
+ print('\nArch =', Arch)
+ print('Filename =', M.Header[Arch].FileName)
+ print('FullPath =', M.Header[Arch].FullPath)
+ print('BaseName =', M.Header[Arch].Name)
+ print('Guid =', M.Header[Arch].Guid)
+ print('Version =', M.Header[Arch].Version)
+ print('DscSpecification =', M.Header[Arch].DscSpecification)
+ print('SkuId =', M.Header[Arch].SkuIdName)
+ print('SupArchList =', M.Header[Arch].SupArchList)
+ print('BuildTargets =', M.Header[Arch].BuildTargets)
+ print('OutputDirectory =', M.Header[Arch].OutputDirectory)
+ print('BuildNumber =', M.Header[Arch].BuildNumber)
+ print('MakefileName =', M.Header[Arch].MakefileName)
+ print('BsBaseAddress =', M.Header[Arch].BsBaseAddress)
+ print('RtBaseAddress =', M.Header[Arch].RtBaseAddress)
+ print('Define =', M.Header[Arch].Define)
+ print('Fdf =', M.FlashDefinitionFile.FilePath)
+ print('\nBuildOptions =', M.BuildOptions, M.BuildOptions.IncludeFiles)
for Item in M.BuildOptions.BuildOptionList:
- print '\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList
- print '\nSkuIds =', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFiles
- print '\nLibraries =', M.Libraries, M.Libraries.IncludeFiles
+ print('\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList)
+ print('\nSkuIds =', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFiles)
+ print('\nLibraries =', M.Libraries, M.Libraries.IncludeFiles)
for Item in M.Libraries.LibraryList:
- print '\t', Item.FilePath, Item.SupArchList, Item.Define
- print '\nLibraryClasses =', M.LibraryClasses, M.LibraryClasses.IncludeFiles
+ print('\t', Item.FilePath, Item.SupArchList, Item.Define)
+ print('\nLibraryClasses =', M.LibraryClasses, M.LibraryClasses.IncludeFiles)
for Item in M.LibraryClasses.LibraryList:
- print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item.SupArchList, Item.Define
- print '\nPcds =', M.DynamicPcdBuildDefinitions
+ print('\t', Item.Name, Item.FilePath, Item.SupModuleList, Item.SupArchList, Item.Define)
+ print('\nPcds =', M.DynamicPcdBuildDefinitions)
for Item in M.DynamicPcdBuildDefinitions:
- print '\tCname=', Item.CName, 'TSG=', Item.TokenSpaceGuidCName, 'Value=', Item.DefaultValue, 'Token=', Item.Token, 'Type=', Item.ItemType, 'Datum=', Item.DatumType, 'Size=', Item.MaxDatumSize, 'Arch=', Item.SupArchList, Item.SkuInfoList
+ print('\tCname=', Item.CName, 'TSG=', Item.TokenSpaceGuidCName, 'Value=', Item.DefaultValue, 'Token=', Item.Token, 'Type=', Item.ItemType, 'Datum=', Item.DatumType, 'Size=', Item.MaxDatumSize, 'Arch=', Item.SupArchList, Item.SkuInfoList)
for Sku in Item.SkuInfoList.values():
- print '\t\t', str(Sku)
- print '\nComponents =', M.Modules.ModuleList, M.Modules.IncludeFiles
+ print('\t\t', str(Sku))
+ print('\nComponents =', M.Modules.ModuleList, M.Modules.IncludeFiles)
for Item in M.Modules.ModuleList:
- print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList
+ print('\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList)
for Lib in Item.LibraryClasses.LibraryList:
- print '\t\tLib:', Lib.Name, Lib.FilePath
+ print('\t\tLib:', Lib.Name, Lib.FilePath)
for Bo in Item.ModuleSaBuildOption.BuildOptionList:
- print '\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain, Bo.Option
+ print('\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain, Bo.Option)
for Pcd in Item.PcdBuildDefinitions:
- print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType
+ print('\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType)
##
#
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
index f22a545b77ce..ed85e4ee0b06 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os, sys, time
from DataType import *
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -39,7 +40,7 @@ class EdkIIWorkspace:
# Check environment valiable 'WORKSPACE'
#
if os.environ.get('WORKSPACE') == None:
- print 'ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.'
+ print('ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.')
return False
self.CurrentWorkingDir = os.getcwd()
@@ -76,18 +77,18 @@ class EdkIIWorkspace:
if self.PrintRunTime:
Seconds = int(time.time() - self.StartTime)
if Seconds < 60:
- print 'Run Time: %d seconds' % (Seconds)
+ print('Run Time: %d seconds' % (Seconds))
else:
Minutes = Seconds / 60
Seconds = Seconds % 60
if Minutes < 60:
- print 'Run Time: %d minutes %d seconds' % (Minutes, Seconds)
+ print('Run Time: %d minutes %d seconds' % (Minutes, Seconds))
else:
Hours = Minutes / 60
Minutes = Minutes % 60
- print 'Run Time: %d hours %d minutes %d seconds' % (Hours, Minutes, Seconds)
+ print('Run Time: %d hours %d minutes %d seconds' % (Hours, Minutes, Seconds))
if self.RunStatus != '':
- print self.RunStatus
+ print(self.RunStatus)
## Convert to a workspace relative filename
#
@@ -136,7 +137,7 @@ class EdkIIWorkspace:
#
def XmlParseFile (self, FileName):
if self.Verbose:
- print FileName
+ print(FileName)
return XmlParseFile (self.WorkspaceFile(FileName))
## Convert a XML section
@@ -150,7 +151,7 @@ class EdkIIWorkspace:
#
def XmlParseFileSection (self, FileName, SectionTag):
if self.Verbose:
- print FileName
+ print(FileName)
return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)
## Save a XML file
@@ -164,7 +165,7 @@ class EdkIIWorkspace:
#
def XmlSaveFile (self, Dom, FileName):
if self.Verbose:
- print FileName
+ print(FileName)
return XmlSaveFile (Dom, self.WorkspaceFile(FileName))
## Convert Text File To Dictionary
@@ -182,7 +183,7 @@ class EdkIIWorkspace:
#
def ConvertTextFileToDictionary(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
if self.Verbose:
- print FileName
+ print(FileName)
return ConvertTextFileToDictionary(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter)
## Convert Dictionary To Text File
@@ -200,7 +201,7 @@ class EdkIIWorkspace:
#
def ConvertDictionaryToTextFile(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
if self.Verbose:
- print FileName
+ print(FileName)
return ConvertDictionaryToTextFile(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter)
## Convert Text File To Dictionary
@@ -317,4 +318,4 @@ def CreateFile(Directory, FileName, Mode='w'):
#
if __name__ == '__main__':
# Nothing to do here. Could do some unit tests
- pass
\ No newline at end of file
+ pass
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
index d6df01d4ce06..a2f7c94c1ca7 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os, string, copy, pdb, copy
import EdkLogger
import DataType
@@ -1568,89 +1569,89 @@ class WorkspaceBuild(object):
# Print each item of the workspacebuild with (Key = Value) pair
#
def ShowWorkspaceBuild(self):
- print self.DscDatabase
- print self.InfDatabase
- print self.DecDatabase
- print 'SupArchList', self.SupArchList
- print 'BuildTarget', self.BuildTarget
- print 'SkuId', self.SkuId
+ print(self.DscDatabase)
+ print(self.InfDatabase)
+ print(self.DecDatabase)
+ print('SupArchList', self.SupArchList)
+ print('BuildTarget', self.BuildTarget)
+ print('SkuId', self.SkuId)
for Arch in self.SupArchList:
- print Arch
- print 'Platform'
+ print(Arch)
+ print('Platform')
for Platform in self.Build[Arch].PlatformDatabase.keys():
P = self.Build[Arch].PlatformDatabase[Platform]
- print 'DescFilePath = ', P.DescFilePath
- print 'PlatformName = ', P.PlatformName
- print 'Guid = ', P.Guid
- print 'Version = ', P.Version
- print 'OutputDirectory = ', P.OutputDirectory
- print 'FlashDefinition = ', P.FlashDefinition
- print 'SkuIds = ', P.SkuIds
- print 'Modules = ', P.Modules
- print 'LibraryClasses = ', P.LibraryClasses
- print 'Pcds = ', P.Pcds
+ print('DescFilePath = ', P.DescFilePath)
+ print('PlatformName = ', P.PlatformName)
+ print('Guid = ', P.Guid)
+ print('Version = ', P.Version)
+ print('OutputDirectory = ', P.OutputDirectory)
+ print('FlashDefinition = ', P.FlashDefinition)
+ print('SkuIds = ', P.SkuIds)
+ print('Modules = ', P.Modules)
+ print('LibraryClasses = ', P.LibraryClasses)
+ print('Pcds = ', P.Pcds)
for item in P.Pcds.keys():
- print P.Pcds[item]
- print 'BuildOptions = ', P.BuildOptions
- print ''
+ print(P.Pcds[item])
+ print('BuildOptions = ', P.BuildOptions)
+ print('')
# End of Platform
- print 'package'
+ print('package')
for Package in self.Build[Arch].PackageDatabase.keys():
P = self.Build[Arch].PackageDatabase[Package]
- print 'DescFilePath = ', P.DescFilePath
- print 'PackageName = ', P.PackageName
- print 'Guid = ', P.Guid
- print 'Version = ', P.Version
- print 'Protocols = ', P.Protocols
- print 'Ppis = ', P.Ppis
- print 'Guids = ', P.Guids
- print 'Includes = ', P.Includes
- print 'LibraryClasses = ', P.LibraryClasses
- print 'Pcds = ', P.Pcds
+ print('DescFilePath = ', P.DescFilePath)
+ print('PackageName = ', P.PackageName)
+ print('Guid = ', P.Guid)
+ print('Version = ', P.Version)
+ print('Protocols = ', P.Protocols)
+ print('Ppis = ', P.Ppis)
+ print('Guids = ', P.Guids)
+ print('Includes = ', P.Includes)
+ print('LibraryClasses = ', P.LibraryClasses)
+ print('Pcds = ', P.Pcds)
for item in P.Pcds.keys():
- print P.Pcds[item]
- print ''
+ print(P.Pcds[item])
+ print('')
# End of Package
- print 'module'
+ print('module')
for Module in self.Build[Arch].ModuleDatabase.keys():
P = self.Build[Arch].ModuleDatabase[Module]
- print 'DescFilePath = ', P.DescFilePath
- print 'BaseName = ', P.BaseName
- print 'ModuleType = ', P.ModuleType
- print 'Guid = ', P.Guid
- print 'Version = ', P.Version
- print 'CustomMakefile = ', P.CustomMakefile
- print 'Specification = ', P.Specification
- print 'Shadow = ', P.Shadow
- print 'PcdIsDriver = ', P.PcdIsDriver
+ print('DescFilePath = ', P.DescFilePath)
+ print('BaseName = ', P.BaseName)
+ print('ModuleType = ', P.ModuleType)
+ print('Guid = ', P.Guid)
+ print('Version = ', P.Version)
+ print('CustomMakefile = ', P.CustomMakefile)
+ print('Specification = ', P.Specification)
+ print('Shadow = ', P.Shadow)
+ print('PcdIsDriver = ', P.PcdIsDriver)
for Lib in P.LibraryClass:
- print 'LibraryClassDefinition = ', Lib.LibraryClass, 'SupModList = ', Lib.SupModList
- print 'ModuleEntryPointList = ', P.ModuleEntryPointList
- print 'ModuleUnloadImageList = ', P.ModuleUnloadImageList
- print 'ConstructorList = ', P.ConstructorList
- print 'DestructorList = ', P.DestructorList
+ print('LibraryClassDefinition = ', Lib.LibraryClass, 'SupModList = ', Lib.SupModList)
+ print('ModuleEntryPointList = ', P.ModuleEntryPointList)
+ print('ModuleUnloadImageList = ', P.ModuleUnloadImageList)
+ print('ConstructorList = ', P.ConstructorList)
+ print('DestructorList = ', P.DestructorList)
- print 'Binaries = '
+ print('Binaries = ')
for item in P.Binaries:
- print item.BinaryFile, item.FeatureFlag, item.SupArchList
- print 'Sources = '
+ print(item.BinaryFile, item.FeatureFlag, item.SupArchList)
+ print('Sources = ')
for item in P.Sources:
- print item.SourceFile
- print 'LibraryClasses = ', P.LibraryClasses
- print 'Protocols = ', P.Protocols
- print 'Ppis = ', P.Ppis
- print 'Guids = ', P.Guids
- print 'Includes = ', P.Includes
- print 'Packages = ', P.Packages
- print 'Pcds = ', P.Pcds
+ print(item.SourceFile)
+ print('LibraryClasses = ', P.LibraryClasses)
+ print('Protocols = ', P.Protocols)
+ print('Ppis = ', P.Ppis)
+ print('Guids = ', P.Guids)
+ print('Includes = ', P.Includes)
+ print('Packages = ', P.Packages)
+ print('Pcds = ', P.Pcds)
for item in P.Pcds.keys():
- print P.Pcds[item]
- print 'BuildOptions = ', P.BuildOptions
- print 'Depex = ', P.Depex
- print ''
+ print(P.Pcds[item])
+ print('BuildOptions = ', P.BuildOptions)
+ print('Depex = ', P.Depex)
+ print('')
# End of Module
##
@@ -1659,12 +1660,12 @@ class WorkspaceBuild(object):
# script.
#
if __name__ == '__main__':
- print 'Start!', time.strftime('%H:%M:%S', time.localtime())
+ print('Start!', time.strftime('%H:%M:%S', time.localtime()))
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
W = os.getenv('WORKSPACE')
Ewb = WorkspaceBuild('Nt32Pkg/Nt32Pkg.dsc', W)
Ewb.GenBuildDatabase({('PcdDevicePathSupportDevicePathFromText', 'gEfiMdeModulePkgTokenSpaceGuid') : 'KKKKKKKKKKKKKKKKKKKKK'}, ['Test.Inf'])
- print 'Done!', time.strftime('%H:%M:%S', time.localtime())
+ print('Done!', time.strftime('%H:%M:%S', time.localtime()))
Ewb.ShowWorkspaceBuild()
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 216694325f96..80e527dd3688 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -12,6 +12,7 @@
## Import Modules
#
+from __future__ import print_function
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
@@ -883,10 +884,10 @@ if __name__ == '__main__':
if input in 'qQ':
break
try:
- print ValueExpression(input)(True)
- print ValueExpression(input)(False)
+ print(ValueExpression(input)(True))
+ print(ValueExpression(input)(False))
except WrnExpression as Ex:
- print Ex.result
- print str(Ex)
+ print(Ex.result)
+ print(str(Ex))
except Exception as Ex:
- print str(Ex)
+ print(str(Ex))
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py
index ac03c3fef5bb..f2741616c46f 100644
--- a/BaseTools/Source/Python/Common/FdfParserLite.py
+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import re
import Common.LongFilePathOs as os
@@ -1269,8 +1270,8 @@ class FdfParser(object):
self.__UndoToken()
if not self.__IsToken("[FD.", True):
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
- % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
+ print('Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
+ % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine))
raise Warning("expected [FD.] At Line ", self.FileName, self.CurrentLineNumber)
FdName = self.__GetUiName()
@@ -1837,8 +1838,8 @@ class FdfParser(object):
self.__UndoToken()
if not self.__IsToken("[FV.", True):
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
- % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
+ print('Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
+ % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine))
raise Warning("Unknown Keyword At Line ", self.FileName, self.CurrentLineNumber)
FvName = self.__GetUiName()
@@ -2643,8 +2644,8 @@ class FdfParser(object):
self.__UndoToken()
if not self.__IsToken("[CAPSULE.", True):
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
- % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
+ print('Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
+ % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine))
raise Warning("expected [Capsule.] At Line ", self.FileName, self.CurrentLineNumber)
CapsuleObj = CommonDataClass.FdfClass.CapsuleClassObject()
@@ -2766,8 +2767,8 @@ class FdfParser(object):
self.__UndoToken()
if not self.__IsToken("[Rule.", True):
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
- % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
+ print('Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
+ % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine))
raise Warning("expected [Rule.] At Line ", self.FileName, self.CurrentLineNumber)
if not self.__SkipToToken("."):
@@ -3357,8 +3358,8 @@ class FdfParser(object):
self.__UndoToken()
if not self.__IsToken("[VTF.", True):
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
- % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
+ print('Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
+ % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine))
raise Warning("expected [VTF.] At Line ", self.FileName, self.CurrentLineNumber)
if not self.__SkipToToken("."):
@@ -3650,7 +3651,7 @@ class FdfParser(object):
raise Warning(LogStr)
except Warning:
- print LogStr
+ print(LogStr)
finally:
return CycleRefExists
@@ -3660,7 +3661,7 @@ if __name__ == "__main__":
try:
test_file = sys.argv[1]
except IndexError as v:
- print "Usage: %s filename" % sys.argv[0]
+ print("Usage: %s filename" % sys.argv[0])
sys.exit(1)
parser = FdfParser(test_file)
@@ -3668,7 +3669,7 @@ if __name__ == "__main__":
parser.ParseFile()
parser.CycleReferenceCheck()
except Warning as X:
- print X.message
+ print(X.message)
else:
- print "Success!"
+ print("Success!")
diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py
index f24e4e41a0c1..fe82ffd8eb4e 100644
--- a/BaseTools/Source/Python/Common/InfClassObject.py
+++ b/BaseTools/Source/Python/Common/InfClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import EdkLogger
@@ -447,79 +448,79 @@ class Inf(InfObject):
def ShowModule(self):
M = self.Module
for Arch in M.Header.keys():
- print '\nArch =', Arch
- print 'Filename =', M.Header[Arch].FileName
- print 'FullPath =', M.Header[Arch].FullPath
- print 'BaseName =', M.Header[Arch].Name
- print 'Guid =', M.Header[Arch].Guid
- print 'Version =', M.Header[Arch].Version
- print 'InfVersion =', M.Header[Arch].InfVersion
- print 'UefiSpecificationVersion =', M.Header[Arch].UefiSpecificationVersion
- print 'EdkReleaseVersion =', M.Header[Arch].EdkReleaseVersion
- print 'ModuleType =', M.Header[Arch].ModuleType
- print 'BinaryModule =', M.Header[Arch].BinaryModule
- print 'ComponentType =', M.Header[Arch].ComponentType
- print 'MakefileName =', M.Header[Arch].MakefileName
- print 'BuildNumber =', M.Header[Arch].BuildNumber
- print 'BuildType =', M.Header[Arch].BuildType
- print 'FfsExt =', M.Header[Arch].FfsExt
- print 'FvExt =', M.Header[Arch].FvExt
- print 'SourceFv =', M.Header[Arch].SourceFv
- print 'PcdIsDriver =', M.Header[Arch].PcdIsDriver
- print 'TianoEdkFlashMap_h =', M.Header[Arch].TianoEdkFlashMap_h
- print 'Shadow =', M.Header[Arch].Shadow
- print 'LibraryClass =', M.Header[Arch].LibraryClass
+ print('\nArch =', Arch)
+ print('Filename =', M.Header[Arch].FileName)
+ print('FullPath =', M.Header[Arch].FullPath)
+ print('BaseName =', M.Header[Arch].Name)
+ print('Guid =', M.Header[Arch].Guid)
+ print('Version =', M.Header[Arch].Version)
+ print('InfVersion =', M.Header[Arch].InfVersion)
+ print('UefiSpecificationVersion =', M.Header[Arch].UefiSpecificationVersion)
+ print('EdkReleaseVersion =', M.Header[Arch].EdkReleaseVersion)
+ print('ModuleType =', M.Header[Arch].ModuleType)
+ print('BinaryModule =', M.Header[Arch].BinaryModule)
+ print('ComponentType =', M.Header[Arch].ComponentType)
+ print('MakefileName =', M.Header[Arch].MakefileName)
+ print('BuildNumber =', M.Header[Arch].BuildNumber)
+ print('BuildType =', M.Header[Arch].BuildType)
+ print('FfsExt =', M.Header[Arch].FfsExt)
+ print('FvExt =', M.Header[Arch].FvExt)
+ print('SourceFv =', M.Header[Arch].SourceFv)
+ print('PcdIsDriver =', M.Header[Arch].PcdIsDriver)
+ print('TianoEdkFlashMap_h =', M.Header[Arch].TianoEdkFlashMap_h)
+ print('Shadow =', M.Header[Arch].Shadow)
+ print('LibraryClass =', M.Header[Arch].LibraryClass)
for Item in M.Header[Arch].LibraryClass:
- print Item.LibraryClass, DataType.TAB_VALUE_SPLIT.join(Item.SupModuleList)
- print 'CustomMakefile =', M.Header[Arch].CustomMakefile
- print 'Define =', M.Header[Arch].Define
- print 'Specification =', M.Header[Arch].Specification
+ print(Item.LibraryClass, DataType.TAB_VALUE_SPLIT.join(Item.SupModuleList))
+ print('CustomMakefile =', M.Header[Arch].CustomMakefile)
+ print('Define =', M.Header[Arch].Define)
+ print('Specification =', M.Header[Arch].Specification)
for Item in self.Module.ExternImages:
- print '\nEntry_Point = %s, UnloadImage = %s' % (Item.ModuleEntryPoint, Item.ModuleUnloadImage)
+ print('\nEntry_Point = %s, UnloadImage = %s' % (Item.ModuleEntryPoint, Item.ModuleUnloadImage))
for Item in self.Module.ExternLibraries:
- print 'Constructor = %s, Destructor = %s' % (Item.Constructor, Item.Destructor)
- print '\nBuildOptions =', M.BuildOptions
+ print('Constructor = %s, Destructor = %s' % (Item.Constructor, Item.Destructor))
+ print('\nBuildOptions =', M.BuildOptions)
for Item in M.BuildOptions:
- print Item.ToolChainFamily, Item.ToolChain, Item.Option, Item.SupArchList
- print '\nIncludes =', M.Includes
+ print(Item.ToolChainFamily, Item.ToolChain, Item.Option, Item.SupArchList)
+ print('\nIncludes =', M.Includes)
for Item in M.Includes:
- print Item.FilePath, Item.SupArchList
- print '\nLibraries =', M.Libraries
+ print(Item.FilePath, Item.SupArchList)
+ print('\nLibraries =', M.Libraries)
for Item in M.Libraries:
- print Item.Library, Item.SupArchList
- print '\nLibraryClasses =', M.LibraryClasses
+ print(Item.Library, Item.SupArchList)
+ print('\nLibraryClasses =', M.LibraryClasses)
for Item in M.LibraryClasses:
- print Item.LibraryClass, Item.RecommendedInstance, Item.FeatureFlag, Item.SupModuleList, Item.SupArchList, Item.Define
- print '\nPackageDependencies =', M.PackageDependencies
+ print(Item.LibraryClass, Item.RecommendedInstance, Item.FeatureFlag, Item.SupModuleList, Item.SupArchList, Item.Define)
+ print('\nPackageDependencies =', M.PackageDependencies)
for Item in M.PackageDependencies:
- print Item.FilePath, Item.SupArchList, Item.FeatureFlag
- print '\nNmake =', M.Nmake
+ print(Item.FilePath, Item.SupArchList, Item.FeatureFlag)
+ print('\nNmake =', M.Nmake)
for Item in M.Nmake:
- print Item.Name, Item.Value, Item.SupArchList
- print '\nPcds =', M.PcdCodes
+ print(Item.Name, Item.Value, Item.SupArchList)
+ print('\nPcds =', M.PcdCodes)
for Item in M.PcdCodes:
- print '\tCName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList
- print '\nSources =', M.Sources
+ print('\tCName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList)
+ print('\nSources =', M.Sources)
for Source in M.Sources:
- print Source.SourceFile, 'Fam=', Source.ToolChainFamily, 'Pcd=', Source.FeatureFlag, 'Tag=', Source.TagName, 'ToolCode=', Source.ToolCode, Source.SupArchList
- print '\nUserExtensions =', M.UserExtensions
+ print(Source.SourceFile, 'Fam=', Source.ToolChainFamily, 'Pcd=', Source.FeatureFlag, 'Tag=', Source.TagName, 'ToolCode=', Source.ToolCode, Source.SupArchList)
+ print('\nUserExtensions =', M.UserExtensions)
for UserExtension in M.UserExtensions:
- print UserExtension.UserID, UserExtension.Identifier, UserExtension.Content
- print '\nGuids =', M.Guids
+ print(UserExtension.UserID, UserExtension.Identifier, UserExtension.Content)
+ print('\nGuids =', M.Guids)
for Item in M.Guids:
- print Item.CName, Item.SupArchList, Item.FeatureFlag
- print '\nProtocols =', M.Protocols
+ print(Item.CName, Item.SupArchList, Item.FeatureFlag)
+ print('\nProtocols =', M.Protocols)
for Item in M.Protocols:
- print Item.CName, Item.SupArchList, Item.FeatureFlag
- print '\nPpis =', M.Ppis
+ print(Item.CName, Item.SupArchList, Item.FeatureFlag)
+ print('\nPpis =', M.Ppis)
for Item in M.Ppis:
- print Item.CName, Item.SupArchList, Item.FeatureFlag
- print '\nDepex =', M.Depex
+ print(Item.CName, Item.SupArchList, Item.FeatureFlag)
+ print('\nDepex =', M.Depex)
for Item in M.Depex:
- print Item.Depex, Item.SupArchList, Item.Define
- print '\nBinaries =', M.Binaries
+ print(Item.Depex, Item.SupArchList, Item.Define)
+ print('\nBinaries =', M.Binaries)
for Binary in M.Binaries:
- print 'Type=', Binary.FileType, 'Target=', Binary.Target, 'Name=', Binary.BinaryFile, 'FeatureFlag=', Binary.FeatureFlag, 'SupArchList=', Binary.SupArchList
+ print('Type=', Binary.FileType, 'Target=', Binary.Target, 'Name=', Binary.BinaryFile, 'FeatureFlag=', Binary.FeatureFlag, 'SupArchList=', Binary.SupArchList)
## Convert [Defines] section content to ModuleHeaderClass
#
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py
index 10b6ac55242b..ee33ae3d3266 100644
--- a/BaseTools/Source/Python/Common/RangeExpression.py
+++ b/BaseTools/Source/Python/Common/RangeExpression.py
@@ -12,6 +12,7 @@
# # Import Modules
#
+from __future__ import print_function
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
@@ -93,11 +94,11 @@ class RangeContainer(object):
self.__clean__()
def dump(self):
- print "----------------------"
+ print("----------------------")
rangelist = ""
for object in self.rangelist:
rangelist = rangelist + "[%d , %d]" % (object.start, object.end)
- print rangelist
+ print(rangelist)
class XOROperatorObject(object):
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 387e51523097..3408cff8d75e 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import EdkLogger
import DataType
@@ -148,7 +149,7 @@ class TargetTxtClassObject(object):
KeyList = Dict.keys()
for Key in KeyList:
if Dict[Key] != '':
- print Key + ' = ' + str(Dict[Key])
+ print(Key + ' = ' + str(Dict[Key]))
## Print the dictionary
#
@@ -161,9 +162,9 @@ class TargetTxtClassObject(object):
if type(List) == type([]):
if len(List) > 0:
if Key.find(TAB_SPLIT) != -1:
- print "\n" + Key
+ print("\n" + Key)
for Item in List:
- print Item
+ print(Item)
## TargetTxtDict
#
# Load target.txt in input Conf dir
@@ -185,6 +186,6 @@ def TargetTxtDict(ConfDir):
if __name__ == '__main__':
pass
Target = TargetTxtDict(os.getenv("WORKSPACE"))
- print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]
- print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]
- print Target.TargetTxtDictionary
+ print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER])
+ print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET])
+ print(Target.TargetTxtDictionary)
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 14ccabe833db..a6c1fb70bd7d 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -15,6 +15,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 Common.LongFilePathOs as os
import re
import Common.EdkLogger as EdkLogger
@@ -249,7 +250,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
except Exception as X:
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X)))
(out, error) = PopenObject.communicate()
- print out
+ print(out)
while PopenObject.returncode == None :
PopenObject.wait()
diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py
index 39883aca07c4..d1b6aed71087 100644
--- a/BaseTools/Source/Python/Ecc/CParser.py
+++ b/BaseTools/Source/Python/Ecc/CParser.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
from antlr3 import *
@@ -109,7 +110,7 @@ class CParser(Parser):
def printTokenInfo(self, line, offset, tokenText):
- print str(line)+ ',' + str(offset) + ':' + str(tokenText)
+ print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):
PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
index 171600feebf9..7bdb3cc3aea5 100644
--- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
@@ -16,6 +16,7 @@
# Import Modules
#
+from __future__ import print_function
import re
import Common.LongFilePathOs as os
import sys
@@ -567,58 +568,58 @@ class CodeFragmentCollector:
def PrintFragments(self):
- print '################# ' + self.FileName + '#####################'
+ print('################# ' + self.FileName + '#####################')
- print '/****************************************/'
- print '/*************** COMMENTS ***************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/*************** COMMENTS ***************/')
+ print('/****************************************/')
for comment in FileProfile.CommentList:
- print str(comment.StartPos) + comment.Content
+ print(str(comment.StartPos) + comment.Content)
- print '/****************************************/'
- print '/********* PREPROCESS DIRECTIVES ********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* PREPROCESS DIRECTIVES ********/')
+ print('/****************************************/')
for pp in FileProfile.PPDirectiveList:
- print str(pp.StartPos) + pp.Content
+ print(str(pp.StartPos) + pp.Content)
- print '/****************************************/'
- print '/********* VARIABLE DECLARATIONS ********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* VARIABLE DECLARATIONS ********/')
+ print('/****************************************/')
for var in FileProfile.VariableDeclarationList:
- print str(var.StartPos) + var.Modifier + ' '+ var.Declarator
+ print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)
- print '/****************************************/'
- print '/********* FUNCTION DEFINITIONS *********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* FUNCTION DEFINITIONS *********/')
+ print('/****************************************/')
for func in FileProfile.FunctionDefinitionList:
- print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)
+ print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))
- print '/****************************************/'
- print '/************ ENUMERATIONS **************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/************ ENUMERATIONS **************/')
+ print('/****************************************/')
for enum in FileProfile.EnumerationDefinitionList:
- print str(enum.StartPos) + enum.Content
+ print(str(enum.StartPos) + enum.Content)
- print '/****************************************/'
- print '/*********** STRUCTS/UNIONS *************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/*********** STRUCTS/UNIONS *************/')
+ print('/****************************************/')
for su in FileProfile.StructUnionDefinitionList:
- print str(su.StartPos) + su.Content
+ print(str(su.StartPos) + su.Content)
- print '/****************************************/'
- print '/********* PREDICATE EXPRESSIONS ********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* PREDICATE EXPRESSIONS ********/')
+ print('/****************************************/')
for predexp in FileProfile.PredicateExpressionList:
- print str(predexp.StartPos) + predexp.Content
+ print(str(predexp.StartPos) + predexp.Content)
- print '/****************************************/'
- print '/************** TYPEDEFS ****************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/************** TYPEDEFS ****************/')
+ print('/****************************************/')
for typedef in FileProfile.TypedefDefinitionList:
- print str(typedef.StartPos) + typedef.ToType
+ print(str(typedef.StartPos) + typedef.ToType)
if __name__ == "__main__":
collector = CodeFragmentCollector(sys.argv[1])
collector.PreprocessFile()
- print "For Test."
+ print("For Test.")
diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py
index b523858e1b1f..c3bbba09b744 100644
--- a/BaseTools/Source/Python/Ecc/Configuration.py
+++ b/BaseTools/Source/Python/Ecc/Configuration.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import Common.EdkLogger as EdkLogger
from Common.DataType import *
@@ -315,6 +316,6 @@ class Configuration(object):
self.__dict__[List[0]] = List[1]
def ShowMe(self):
- print self.Filename
+ print(self.Filename)
for Key in self.__dict__.keys():
- print Key, '=', self.__dict__[Key]
+ print(Key, '=', self.__dict__[Key])
diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py
index b0882afa6289..bde41c3a4b57 100644
--- a/BaseTools/Source/Python/Ecc/Exception.py
+++ b/BaseTools/Source/Python/Ecc/Exception.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
from Xml.XmlRoutines import *
import Common.LongFilePathOs as os
@@ -84,4 +85,4 @@ class ExceptionCheck(object):
#
if __name__ == '__main__':
El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')
- print El.ExceptionList
+ print(El.ExceptionList)
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
index a4057ceb1775..5bb7759e2120 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import Common.EdkLogger as EdkLogger
@@ -99,7 +100,7 @@ class Table(object):
try:
self.Cur.execute(SqlCommand)
except Exception as e:
- print "An error occurred when Drop a table:", e.args[0]
+ print("An error occurred when Drop a table:", e.args[0])
## Get count
#
diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
index 4ce8edf5573a..eb76f4e6d54a 100644
--- a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
+++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import xml.dom.minidom
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -215,7 +216,7 @@ def XmlParseFile(FileName):
XmlFile.close()
return Dom
except Exception as X:
- print X
+ print(X)
return ""
# This acts like the main() function for the script, unless it is 'import'ed
@@ -225,5 +226,5 @@ if __name__ == '__main__':
A = CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']], [['A', '1'], ['B', '2']])
B = CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']], [['A', '1'], ['B', '2']])
C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG'])
- print C.toprettyxml(indent = " ")
+ print(C.toprettyxml(indent = " "))
pass
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index 8a4b10727a07..7f83387c08c8 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import print_function
import sys
import Common.LongFilePathOs as os
import re
@@ -2279,7 +2280,7 @@ def CheckDoxygenTripleForwardSlash(FullFileName):
for Result in ResultSet:
CommentSet.append(Result)
except:
- print 'Unrecognized chars in comment of file %s', FullFileName
+ print('Unrecognized chars in comment of file %s', FullFileName)
for Result in CommentSet:
@@ -2432,7 +2433,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
for Result in ResultSet:
CommentSet.append(Result)
except:
- print 'Unrecognized chars in comment of file %s', FullFileName
+ print('Unrecognized chars in comment of file %s', FullFileName)
# Func Decl check
SqlStatement = """ select Modifier, Name, StartLine, ID, Value
@@ -2463,7 +2464,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
for Result in ResultSet:
CommentSet.append(Result)
except:
- print 'Unrecognized chars in comment of file %s', FullFileName
+ print('Unrecognized chars in comment of file %s', FullFileName)
SqlStatement = """ select Modifier, Header, StartLine, ID, Name
from Function
@@ -2628,9 +2629,9 @@ if __name__ == '__main__':
try:
test_file = sys.argv[1]
except IndexError as v:
- print "Usage: %s filename" % sys.argv[0]
+ print("Usage: %s filename" % sys.argv[0])
sys.exit(1)
MsgList = CheckFuncHeaderDoxygenComments(test_file)
for Msg in MsgList:
- print Msg
- print 'Done!'
+ print(Msg)
+ print('Done!')
diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Python/Eot/CParser.py
index 39883aca07c4..d1b6aed71087 100644
--- a/BaseTools/Source/Python/Eot/CParser.py
+++ b/BaseTools/Source/Python/Eot/CParser.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
from antlr3 import *
@@ -109,7 +110,7 @@ class CParser(Parser):
def printTokenInfo(self, line, offset, tokenText):
- print str(line)+ ',' + str(offset) + ':' + str(tokenText)
+ print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):
PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
index bb78a0f882d5..5d5336bee463 100644
--- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import re
import Common.LongFilePathOs as os
import sys
@@ -413,49 +414,49 @@ class CodeFragmentCollector:
#
def PrintFragments(self):
- print '################# ' + self.FileName + '#####################'
+ print('################# ' + self.FileName + '#####################')
- print '/****************************************/'
- print '/*************** ASSIGNMENTS ***************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/*************** ASSIGNMENTS ***************/')
+ print('/****************************************/')
for asign in FileProfile.AssignmentExpressionList:
- print str(asign.StartPos) + asign.Name + asign.Operator + asign.Value
+ print(str(asign.StartPos) + asign.Name + asign.Operator + asign.Value)
- print '/****************************************/'
- print '/********* PREPROCESS DIRECTIVES ********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* PREPROCESS DIRECTIVES ********/')
+ print('/****************************************/')
for pp in FileProfile.PPDirectiveList:
- print str(pp.StartPos) + pp.Content
+ print(str(pp.StartPos) + pp.Content)
- print '/****************************************/'
- print '/********* VARIABLE DECLARATIONS ********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* VARIABLE DECLARATIONS ********/')
+ print('/****************************************/')
for var in FileProfile.VariableDeclarationList:
- print str(var.StartPos) + var.Modifier + ' '+ var.Declarator
+ print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)
- print '/****************************************/'
- print '/********* FUNCTION DEFINITIONS *********/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/********* FUNCTION DEFINITIONS *********/')
+ print('/****************************************/')
for func in FileProfile.FunctionDefinitionList:
- print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)
+ print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))
- print '/****************************************/'
- print '/************ ENUMERATIONS **************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/************ ENUMERATIONS **************/')
+ print('/****************************************/')
for enum in FileProfile.EnumerationDefinitionList:
- print str(enum.StartPos) + enum.Content
+ print(str(enum.StartPos) + enum.Content)
- print '/****************************************/'
- print '/*********** STRUCTS/UNIONS *************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/*********** STRUCTS/UNIONS *************/')
+ print('/****************************************/')
for su in FileProfile.StructUnionDefinitionList:
- print str(su.StartPos) + su.Content
+ print(str(su.StartPos) + su.Content)
- print '/****************************************/'
- print '/************** TYPEDEFS ****************/'
- print '/****************************************/'
+ print('/****************************************/')
+ print('/************** TYPEDEFS ****************/')
+ print('/****************************************/')
for typedef in FileProfile.TypedefDefinitionList:
- print str(typedef.StartPos) + typedef.ToType
+ print(str(typedef.StartPos) + typedef.ToType)
##
#
@@ -464,4 +465,4 @@ class CodeFragmentCollector:
#
if __name__ == "__main__":
- print "For Test."
+ print("For Test.")
diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py
index 6696623aba68..9d8f0864dc41 100644
--- a/BaseTools/Source/Python/Eot/FvImage.py
+++ b/BaseTools/Source/Python/Eot/FvImage.py
@@ -13,6 +13,7 @@
## Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import sys
@@ -1190,17 +1191,17 @@ class PeImage:
self.Machine, self.NumberOfSections, self.SizeOfOptionalHeader = \
self._FileHeader.unpack_from(self._PeImageBuf, self.Offset + FileHeaderOffset)
- print "Machine=%x NumberOfSections=%x SizeOfOptionalHeader=%x" % (self.Machine, self.NumberOfSections, self.SizeOfOptionalHeader)
+ print("Machine=%x NumberOfSections=%x SizeOfOptionalHeader=%x" % (self.Machine, self.NumberOfSections, self.SizeOfOptionalHeader))
# optional header follows the FILE header
OptionalHeaderOffset = FileHeaderOffset + struct.calcsize(self._FileHeaderFormat)
Magic, self.SizeOfImage, SizeOfHeaders, self.Checksum, NumberOfRvaAndSizes = \
self._OptionalHeader32.unpack_from(self._PeImageBuf, self.Offset + OptionalHeaderOffset)
- print "Magic=%x SizeOfImage=%x SizeOfHeaders=%x, Checksum=%x, NumberOfRvaAndSizes=%x" % (Magic, self.SizeOfImage, SizeOfHeaders, self.Checksum, NumberOfRvaAndSizes)
+ print("Magic=%x SizeOfImage=%x SizeOfHeaders=%x, Checksum=%x, NumberOfRvaAndSizes=%x" % (Magic, self.SizeOfImage, SizeOfHeaders, self.Checksum, NumberOfRvaAndSizes))
PeImageSectionTableOffset = OptionalHeaderOffset + self.SizeOfOptionalHeader
PeSections = PeSectionTable(self._PeImageBuf, self.Offset + PeImageSectionTableOffset, self.NumberOfSections)
- print "%x" % PeSections.GetFileAddress(0x3920)
+ print("%x" % PeSections.GetFileAddress(0x3920))
## PeSectionTable() class
#
@@ -1215,7 +1216,7 @@ class PeSectionTable:
SectionHeader = PeSectionHeader(Buf, SectionHeaderOffset)
self._SectionList.append(SectionHeader)
SectionHeaderOffset += len(SectionHeader)
- print SectionHeader
+ print(SectionHeader)
def GetFileAddress(self, Rva):
for PeSection in self._SectionList:
@@ -1412,7 +1413,7 @@ def Main():
Option = GetOptions()
build.main()
except Exception as e:
- print e
+ print(e)
return 1
return 0
@@ -1435,7 +1436,7 @@ if __name__ == '__main__':
fv = FirmwareVolume("FVRECOVERY")
fv.frombuffer(buf, 0, len(buf))
#fv.Dispatch(None)
- print fv
+ print(fv)
elif FilePath.endswith(".efi"):
fd = open(FilePath, 'rb')
buf = array('B')
diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py
index 6bb2c5f9f1d6..f624837f2587 100644
--- a/BaseTools/Source/Python/Eot/InfParserLite.py
+++ b/BaseTools/Source/Python/Eot/InfParserLite.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import Common.EdkLogger as EdkLogger
from Common.DataType import *
@@ -164,8 +165,8 @@ if __name__ == '__main__':
Db.InitDatabase()
P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')
for Inf in P.Sources:
- print Inf
+ print(Inf)
for Item in P.Macros:
- print Item, P.Macros[Item]
+ print(Item, P.Macros[Item])
- Db.Close()
\ No newline at end of file
+ Db.Close()
diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py
index 8199ce5ee73e..c70f62f393a9 100644
--- a/BaseTools/Source/Python/Eot/c.py
+++ b/BaseTools/Source/Python/Eot/c.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import sys
import Common.LongFilePathOs as os
import re
@@ -384,4 +385,4 @@ if __name__ == '__main__':
EdkLogger.SetLevel(EdkLogger.QUIET)
CollectSourceCodeDataIntoDB(sys.argv[1])
- print 'Done!'
+ print('Done!')
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 15b2b792b2e1..d4ba485bcdff 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -16,6 +16,7 @@
##
# Import Modules
#
+from __future__ import print_function
import re
import Fd
@@ -4818,7 +4819,7 @@ if __name__ == "__main__":
try:
test_file = sys.argv[1]
except IndexError as v:
- print "Usage: %s filename" % sys.argv[0]
+ print("Usage: %s filename" % sys.argv[0])
sys.exit(1)
parser = FdfParser(test_file)
@@ -4826,7 +4827,7 @@ if __name__ == "__main__":
parser.ParseFile()
parser.CycleReferenceCheck()
except Warning as X:
- print str(X)
+ print(str(X))
else:
- print "Success!"
+ print("Success!")
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 51b79397337c..b2cc25d46cbc 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
from optparse import OptionParser
import sys
import Common.LongFilePathOs as os
@@ -745,7 +746,7 @@ class GenFds :
ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
for Key in ModuleDict:
ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
- print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
+ print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType)
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index da955fe1a4f7..969f9f2e2137 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import sys
import subprocess
@@ -737,7 +738,7 @@ class GenFdsGlobalVariable:
GenFdsGlobalVariable.InfLogger (out)
GenFdsGlobalVariable.InfLogger (error)
if PopenObject.returncode != 0:
- print "###", cmd
+ print("###", cmd)
EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)
def VerboseLogger (msg):
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index fdad5a44dc3d..127385228fcf 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -17,6 +17,7 @@
#
#====================================== External Libraries ========================================
+from __future__ import print_function
import optparse
import Common.LongFilePathOs as os
import re
@@ -215,7 +216,7 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
if options.mapfile == None or options.efifile == None:
- print parser.get_usage()
+ print(parser.get_usage())
elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):
list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)
if list != None:
@@ -224,6 +225,6 @@ if __name__ == '__main__':
else:
generatePcdTable(list, options.mapfile.replace('.map', '.BinaryPcdTable.txt'))
else:
- print 'Fail to generate Patch PCD Table based on map file and efi file'
+ print('Fail to generate Patch PCD Table based on map file and efi file')
else:
- print 'Fail to generate Patch PCD Table for fail to find map file or efi file!'
+ print('Fail to generate Patch PCD Table for fail to find map file or efi file!')
diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
index de8575676cac..4f79d0f82967 100644
--- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
+++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
@@ -19,6 +19,7 @@
'''
Pkcs7Sign
'''
+from __future__ import print_function
import os
import sys
@@ -113,14 +114,14 @@ if __name__ == '__main__':
try:
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(1)
Version = Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print Version[0]
+ print(Version[0])
#
# Read input file into a buffer and save input filename
@@ -134,7 +135,7 @@ if __name__ == '__main__':
#
OutputDir = os.path.dirname(args.OutputFile)
if not os.path.exists(OutputDir):
- print 'ERROR: The output path does not exist: %s' % OutputDir
+ print('ERROR: The output path does not exist: %s' % OutputDir)
sys.exit(1)
args.OutputFileName = args.OutputFile
@@ -170,7 +171,7 @@ if __name__ == '__main__':
args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb')
args.SignerPrivateCertFile.close()
except:
- print 'ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName)
+ print('ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName))
sys.exit(1)
#
@@ -196,7 +197,7 @@ if __name__ == '__main__':
args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb')
args.OtherPublicCertFile.close()
except:
- print 'ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName)
+ print('ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName))
sys.exit(1)
format = "%dsQ" % len(args.InputFileBuffer)
@@ -242,11 +243,11 @@ if __name__ == '__main__':
args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb')
args.TrustedPublicCertFile.close()
except:
- print 'ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName)
+ print('ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName))
sys.exit(1)
if not args.SignatureSizeStr:
- print "ERROR: please use the option --signature-size to specify the size of the signature data!"
+ print("ERROR: please use the option --signature-size to specify the size of the signature data!")
sys.exit(1)
else:
if args.SignatureSizeStr.upper().startswith('0X'):
@@ -254,10 +255,10 @@ if __name__ == '__main__':
else:
SignatureSize = (long)(args.SignatureSizeStr)
if SignatureSize < 0:
- print "ERROR: The value of option --signature-size can't be set to negative value!"
+ print("ERROR: The value of option --signature-size can't be set to negative value!")
sys.exit(1)
elif SignatureSize > len(args.InputFileBuffer):
- print "ERROR: The value of option --signature-size is exceed the size of the input file !"
+ print("ERROR: The value of option --signature-size is exceed the size of the input file !")
sys.exit(1)
args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize]
@@ -277,7 +278,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.communicate(input=args.SignatureBuffer)[0]
if Process.returncode <> 0:
- print 'ERROR: Verification failed'
+ print('ERROR: Verification failed')
os.remove (args.OutputFileName)
sys.exit(Process.returncode)
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index 95a636966c59..06ed2610271f 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -22,6 +22,7 @@
'''
Rsa2048Sha256GenerateKeys
'''
+from __future__ import print_function
import os
import sys
@@ -75,14 +76,14 @@ if __name__ == '__main__':
try:
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(1)
Version = Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print Version[0]
+ print(Version[0])
args.PemFileName = []
@@ -103,7 +104,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: RSA 2048 key generation failed'
+ print('ERROR: RSA 2048 key generation failed')
sys.exit(Process.returncode)
#
@@ -125,7 +126,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()
if Process.returncode <> 0:
- print 'ERROR: Unable to extract public key from private key'
+ print('ERROR: Unable to extract public key from private key')
sys.exit(Process.returncode)
PublicKey = ''
for Index in range (0, len(PublicKeyHexString), 2):
@@ -138,7 +139,7 @@ if __name__ == '__main__':
Process.stdin.write (PublicKey)
PublicKeyHash = PublicKeyHash + Process.communicate()[0]
if Process.returncode <> 0:
- print 'ERROR: Unable to extract SHA 256 hash of public key'
+ print('ERROR: Unable to extract SHA 256 hash of public key')
sys.exit(Process.returncode)
#
@@ -171,4 +172,4 @@ if __name__ == '__main__':
# If verbose is enabled display the public key in C structure format
#
if args.Verbose:
- print 'PublicKeySha256 = ' + PublicKeyHashC
+ print('PublicKeySha256 = ' + PublicKeyHashC)
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index 1ae6ebb35886..99a5d8aa5a01 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -17,6 +17,7 @@
'''
Rsa2048Sha256Sign
'''
+from __future__ import print_function
import os
import sys
@@ -96,14 +97,14 @@ if __name__ == '__main__':
try:
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(1)
Version = Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print Version[0]
+ print(Version[0])
#
# Read input file into a buffer and save input filename
@@ -117,7 +118,7 @@ if __name__ == '__main__':
#
OutputDir = os.path.dirname(args.OutputFile)
if not os.path.exists(OutputDir):
- print 'ERROR: The output path does not exist: %s' % OutputDir
+ print('ERROR: The output path does not exist: %s' % OutputDir)
sys.exit(1)
args.OutputFileName = args.OutputFile
@@ -144,7 +145,7 @@ if __name__ == '__main__':
args.PrivateKeyFile = open(args.PrivateKeyFileName, 'rb')
args.PrivateKeyFile.close()
except:
- print 'ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName)
+ print('ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName))
sys.exit(1)
#
@@ -202,14 +203,14 @@ if __name__ == '__main__':
# Verify that the Hash Type matches the expected SHA256 type
#
if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID:
- print 'ERROR: unsupport hash GUID'
+ print('ERROR: unsupport hash GUID')
sys.exit(1)
#
# Verify the public key
#
if Header.PublicKey <> PublicKey:
- print 'ERROR: Public key in input file does not match public key from private key file'
+ print('ERROR: Public key in input file does not match public key from private key file')
sys.exit(1)
FullInputFileBuffer = args.InputFileBuffer
@@ -228,7 +229,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.communicate(input=FullInputFileBuffer)
if Process.returncode <> 0:
- print 'ERROR: Verification failed'
+ print('ERROR: Verification failed')
os.remove (args.OutputFileName)
sys.exit(Process.returncode)
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/Python/TargetTool/TargetTool.py
index 882b016bf058..ebed7a0ea7b8 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,
@@ -84,14 +85,14 @@ class TargetTool():
errMsg = ''
for Key in KeyList:
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] == 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:
@@ -110,7 +111,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
@@ -121,7 +122,7 @@ class TargetTool():
fw.write(Line)
for key in self.TargetTxtDictionary.keys():
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 == None:
Line = "%-30s = " % key
@@ -224,25 +225,25 @@ if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
if os.getenv('WORKSPACE') == 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 != 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 != 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 != 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:
diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
index ca21e6995217..afa5b2407ec5 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 b00bba1f8440..84958ae38cef 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
@@ -748,7 +749,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_'):
@@ -1040,12 +1041,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 436dc90e6dd3..074aa311f31d 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 8b4ece2617a1..5f0abcafef27 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 f3b43ee0bc27..626f17426de7 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!')
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 5824266dc4fe..cce7a6273313 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -17,6 +17,7 @@
# This class is used to retrieve information stored in database and convert them
# into PlatformBuildClassObject form for easier use for AutoGen.
#
+from __future__ import print_function
from Common.String import *
from Common.DataType import *
from Common.Misc import *
@@ -909,9 +910,9 @@ class DscBuildData(PlatformBuildClassObject):
for skuid in pcdobj.SkuInfoList:
if pcdobj.Type in (self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]):
for storename in pcdobj.SkuInfoList[skuid].DefaultStoreDict:
- print "PcdCName: %s, SkuName: %s, StoreName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename]))
+ print("PcdCName: %s, SkuName: %s, StoreName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename])))
else:
- print "PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuInfoList[skuid].DefaultValue))
+ print("PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuInfoList[skuid].DefaultValue)))
## Retrieve [BuildOptions]
def _GetBuildOptions(self):
if self._BuildOptions == None:
@@ -1067,7 +1068,7 @@ class DscBuildData(PlatformBuildClassObject):
for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:
str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))
if str_pcd_obj is None:
- print PcdName, PcdGuid
+ print(PcdName, PcdGuid)
raise
if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
@@ -1244,10 +1245,10 @@ class DscBuildData(PlatformBuildClassObject):
if Value[0] == '{' and Value[-1] == '}':
return True
if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
- print 'foo = ', list(Value[2:-1])
+ print('foo = ', list(Value[2:-1]))
return True
if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
- print 'bar = ', list(Value[1:-1])
+ print('bar = ', list(Value[1:-1]))
return True
return False
@@ -1255,11 +1256,11 @@ class DscBuildData(PlatformBuildClassObject):
try:
Process = subprocess.Popen(Command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except:
- print 'ERROR: Can not execute command:', Command
+ print('ERROR: Can not execute command:', Command)
sys.exit(1)
Result = Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: Can not collect output from command:', Command
+ print('ERROR: Can not collect output from command:', Command)
return Result[0], Result[1]
def IntToCString(self, Value, ValueSize):
@@ -1376,7 +1377,7 @@ class DscBuildData(PlatformBuildClassObject):
try:
Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
except Exception:
- print FieldList[FieldName][0]
+ print(FieldList[FieldName][0])
if isinstance(Value, str):
CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
elif IsArray:
@@ -1414,7 +1415,7 @@ class DscBuildData(PlatformBuildClassObject):
try:
Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
except Exception:
- print FieldList[FieldName][0]
+ print(FieldList[FieldName][0])
if isinstance(Value, str):
CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
elif IsArray:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 74fa4d31b109..afc8394efcf0 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import time
@@ -1605,7 +1606,7 @@ class DscParser(MetaFileParser):
try:
self._ValueList[2] = '|'.join(ValList)
except Exception:
- print ValList
+ print(ValList)
def __ProcessComponent(self):
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 0379fd8baf1e..45cdcc89f168 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -16,6 +16,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import re
import StringIO
@@ -2184,7 +2185,7 @@ class Build():
toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')
toolsFile = open(toolsFile, 'wt')
for guidedSectionTool in guidAttribs:
- print >> toolsFile, ' '.join(guidedSectionTool)
+ print(' '.join(guidedSectionTool), file=toolsFile)
toolsFile.close()
## Returns the full path of the tool.
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index 27afd79f2094..c52b8bd94234 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import base64
import os
import os.path
@@ -91,9 +92,9 @@ class BaseToolsTest(unittest.TestCase):
os.remove(path)
def DisplayBinaryData(self, description, data):
- print description, '(base64 encoded):'
+ print(description, '(base64 encoded):')
b64data = base64.b64encode(data)
- print b64data
+ print(b64data)
def DisplayFile(self, fileName):
sys.stdout.write(self.ReadTmpFile(fileName))
diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompress.py
index e14136416211..f6a4a6ae9c5d 100644
--- a/BaseTools/Tests/TianoCompress.py
+++ b/BaseTools/Tests/TianoCompress.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import os
import random
import sys
@@ -52,8 +53,8 @@ class Tests(TestTools.BaseToolsTest):
finish = self.ReadTmpFile('output2')
startEqualsFinish = start == finish
if not startEqualsFinish:
- print
- print 'Original data did not match decompress(compress(data))'
+ print()
+ print('Original data did not match decompress(compress(data))')
self.DisplayBinaryData('original data', start)
self.DisplayBinaryData('after compression', self.ReadTmpFile('output1'))
self.DisplayBinaryData('after decomression', finish)
diff --git a/BaseTools/gcc/mingw-gcc-build.py b/BaseTools/gcc/mingw-gcc-build.py
index 858b4020ef9f..643fec58a457 100755
--- a/BaseTools/gcc/mingw-gcc-build.py
+++ b/BaseTools/gcc/mingw-gcc-build.py
@@ -17,6 +17,7 @@
#
+from __future__ import print_function
from optparse import OptionParser
import os
import shutil
@@ -34,7 +35,7 @@ if sys.version_info < (2, 5):
#
# This script (and edk2 BaseTools) require Python 2.5 or newer
#
- print 'Python version 2.5 or later is required.'
+ print('Python version 2.5 or later is required.')
sys.exit(-1)
#
@@ -146,37 +147,37 @@ class Config:
if not self.options.skip_gcc:
building.append('gcc')
if len(building) == 0:
- print "Nothing will be built!"
- print
- print "Please try using --help and then change the configuration."
+ print("Nothing will be built!")
+ print()
+ print("Please try using --help and then change the configuration.")
return False
- print "Current directory:"
- print " ", self.base_dir
- print "Sources download/extraction:", self.Relative(self.src_dir)
- print "Build directory :", self.Relative(self.build_dir)
- print "Prefix (install) directory :", self.Relative(self.prefix)
- print "Create symlinks directory :", self.Relative(self.symlinks)
- print "Building :", ', '.join(building)
- print
+ print("Current directory:")
+ print(" ", self.base_dir)
+ print("Sources download/extraction:", self.Relative(self.src_dir))
+ print("Build directory :", self.Relative(self.build_dir))
+ print("Prefix (install) directory :", self.Relative(self.prefix))
+ print("Create symlinks directory :", self.Relative(self.symlinks))
+ print("Building :", ', '.join(building))
+ print()
answer = raw_input("Is this configuration ok? (default = no): ")
if (answer.lower() not in ('y', 'yes')):
- print
- print "Please try using --help and then change the configuration."
+ print()
+ print("Please try using --help and then change the configuration.")
return False
if self.arch.lower() == 'ipf':
- print
- print 'Please note that the IPF compiler built by this script has'
- print 'not yet been validated!'
- print
+ print()
+ print('Please note that the IPF compiler built by this script has')
+ print('not yet been validated!')
+ print()
answer = raw_input("Are you sure you want to build it? (default = no): ")
if (answer.lower() not in ('y', 'yes')):
- print
- print "Please try using --help and then change the configuration."
+ print()
+ print("Please try using --help and then change the configuration.")
return False
- print
+ print()
return True
def Relative(self, path):
@@ -275,7 +276,7 @@ class SourceFiles:
wDots = (100 * received * blockSize) / fileSize / 10
if wDots > self.dots:
for i in range(wDots - self.dots):
- print '.',
+ print('.', end=' ')
sys.stdout.flush()
self.dots += 1
@@ -286,18 +287,18 @@ class SourceFiles:
self.dots = 0
local_file = os.path.join(self.config.src_dir, fdata['filename'])
url = fdata['url']
- print 'Downloading %s:' % fname, url
+ print('Downloading %s:' % fname, url)
if retries > 0:
- print '(retry)',
+ print('(retry)', end=' ')
sys.stdout.flush()
completed = False
if os.path.exists(local_file):
md5_pass = self.checkHash(fdata)
if md5_pass:
- print '[md5 match]',
+ print('[md5 match]', end=' ')
else:
- print '[md5 mismatch]',
+ print('[md5 mismatch]', end=' ')
sys.stdout.flush()
completed = md5_pass
@@ -313,32 +314,32 @@ class SourceFiles:
if not completed and os.path.exists(local_file):
md5_pass = self.checkHash(fdata)
if md5_pass:
- print '[md5 match]',
+ print('[md5 match]', end=' ')
else:
- print '[md5 mismatch]',
+ print('[md5 mismatch]', end=' ')
sys.stdout.flush()
completed = md5_pass
if completed:
- print '[done]'
+ print('[done]')
break
else:
- print '[failed]'
- print ' Tried to retrieve', url
- print ' to', local_file
- print 'Possible fixes:'
- print '* If you are behind a web-proxy, try setting the',
- print 'http_proxy environment variable'
- print '* You can try to download this file separately',
- print 'and rerun this script'
+ print('[failed]')
+ print(' Tried to retrieve', url)
+ print(' to', local_file)
+ print('Possible fixes:')
+ print('* If you are behind a web-proxy, try setting the', end=' ')
+ print('http_proxy environment variable')
+ print('* You can try to download this file separately', end=' ')
+ print('and rerun this script')
raise Exception()
except KeyboardInterrupt:
- print '[KeyboardInterrupt]'
+ print('[KeyboardInterrupt]')
return False
except Exception as e:
- print e
+ print(e)
if not completed: return False
@@ -396,7 +397,7 @@ class Extracter:
extractedMd5 = open(extracted).read()
if extractedMd5 != moduleMd5:
- print 'Extracting %s:' % self.config.Relative(local_file)
+ print('Extracting %s:' % self.config.Relative(local_file))
tar = tarfile.open(local_file)
tar.extractall(extractDst)
open(extracted, 'w').write(moduleMd5)
@@ -480,7 +481,7 @@ class Builder:
os.chdir(base_dir)
- print '%s module is now built and installed' % module
+ print('%s module is now built and installed' % module)
def RunCommand(self, cmd, module, stage, skipable=False):
if skipable:
@@ -495,13 +496,13 @@ class Builder:
stderr=subprocess.STDOUT
)
- print '%s [%s] ...' % (module, stage),
+ print('%s [%s] ...' % (module, stage), end=' ')
sys.stdout.flush()
p = popen(cmd)
output = p.stdout.read()
p.wait()
if p.returncode != 0:
- print '[failed!]'
+ print('[failed!]')
logFile = os.path.join(self.config.build_dir, 'log.txt')
f = open(logFile, "w")
f.write(output)
@@ -509,7 +510,7 @@ class Builder:
raise Exception, 'Failed to %s %s\n' % (stage, module) + \
'See output log at %s' % self.config.Relative(logFile)
else:
- print '[done]'
+ print('[done]')
if skipable:
self.MarkBuildStepComplete('%s.%s' % (module, stage))
@@ -526,13 +527,13 @@ class Builder:
linkdst = os.path.join(links_dir, link)
if not os.path.lexists(linkdst):
if not startPrinted:
- print 'Making symlinks in %s:' % self.config.Relative(links_dir),
+ print('Making symlinks in %s:' % self.config.Relative(links_dir), end=' ')
startPrinted = True
- print link,
+ print(link, end=' ')
os.symlink(src, linkdst)
if startPrinted:
- print '[done]'
+ print('[done]')
class App:
"""class App
@@ -551,9 +552,9 @@ class App:
sources = SourceFiles(config)
result = sources.GetAll()
if result:
- print 'All files have been downloaded & verified'
+ print('All files have been downloaded & verified')
else:
- print 'An error occured while downloading a file'
+ print('An error occured while downloading a file')
return
Extracter(sources, config).ExtractAll()
--
2.15.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.