From nobody Mon Dec 23 17:52:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516337029261818.6065121960293; Thu, 18 Jan 2018 20:43:49 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 46CF8222DDC11; Thu, 18 Jan 2018 20:38:24 -0800 (PST) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 656182238B597 for ; Thu, 18 Jan 2018 20:38:21 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Fri, 19 Jan 2018 05:43:39 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org From: Gary Lin To: edk2-devel@lists.01.org Date: Fri, 19 Jan 2018 12:43:03 +0800 Message-Id: <20180119044316.4713-3-glin@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180119044316.4713-1-glin@suse.com> References: <20180119044316.4713-1-glin@suse.com> Subject: [edk2] [PATCH 02/15] BaseTools: Refactor python print statements X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Liming Gao Signed-off-by: Gary Lin --- 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 | 1= 33 ++++++++++---------- BaseTools/Source/Python/Common/Expression.py | = 11 +- BaseTools/Source/Python/Common/FdfParserLite.py | = 29 ++--- BaseTools/Source/Python/Common/InfClassObject.py | 1= 13 ++++++++--------- 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 excepti= on list # +from __future__ import print_function import sys import os import subprocess @@ -86,7 +87,7 @@ if __name__ =3D=3D "__main__": ret =3D main(sys.argv[2:]) =20 except: - print "exiting: exception from " + sys.argv[0] + print("exiting: exception from " + sys.argv[0]) ret =3D 2 =20 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 =20 import sys import argparse @@ -98,7 +99,7 @@ if __name__ =3D=3D '__main__': Buffer =3D 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() =20 # @@ -109,7 +110,7 @@ if __name__ =3D=3D '__main__': # If PcdName is None, then only a PCD value is being requested. Pcd =3D 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__ =3D=3D '__main__': # Pcd =3D ' %s|%s' % (args.PcdName, ByteArray (Buffer)) elif args.MaxSize < len(Buffer): - print 'BinToPcd: error: argument --max-size is smaller than input fi= le.' + print('BinToPcd: error: argument --max-size is smaller than input fi= le.') sys.exit() else: Pcd =3D ' %s|%s|VOID*|%d' % (args.PcdName, ByteArray (Buffer), args= .MaxSize) args.MaxSize =3D len(Buffer) =20 if args.Verbose: - print 'PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections:' - print ' [PcdsFixedAtBuild]' - print ' [PcdsPatchableInModule]' - print ' [PcdsDynamicDefault]' - print ' [PcdsDynamicExDefault]' + print('PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections:') + print(' [PcdsFixedAtBuild]') + print(' [PcdsPatchableInModule]') + print(' [PcdsDynamicDefault]') + print(' [PcdsDynamicExDefault]') elif args.PcdType =3D=3D 'VPD': if args.MaxSize is None: # @@ -143,7 +144,7 @@ if __name__ =3D=3D '__main__': # args.MaxSize =3D len(Buffer) if args.MaxSize < len(Buffer): - print 'BinToPcd: error: argument --max-size is smaller than input fi= le.' + print('BinToPcd: error: argument --max-size is smaller than input fi= le.') sys.exit() if args.Offset is None: # @@ -157,15 +158,15 @@ if __name__ =3D=3D '__main__': # Pcd =3D ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, = ByteArray (Buffer)) if args.Verbose: - print 'PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections' - print ' [PcdsDynamicVpd]' - print ' [PcdsDynamicExVpd]' + print('PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections') + print(' [PcdsDynamicVpd]') + print(' [PcdsDynamicExVpd]') elif args.PcdType =3D=3D 'HII': if args.VariableGuid is None: - print 'BinToPcd: error: argument --variable-guid is required for --t= ype HII.' + print('BinToPcd: error: argument --variable-guid is required for --t= ype HII.') sys.exit() if args.VariableName is None: - print 'BinToPcd: error: argument --variable-name is required for --t= ype HII.' + print('BinToPcd: error: argument --variable-name is required for --t= ype HII.') sys.exit() if args.Offset is None: # @@ -174,9 +175,9 @@ if __name__ =3D=3D '__main__': args.Offset =3D 0 Pcd =3D ' %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 wit= h PCD sections' - print ' [PcdsDynamicHii]' - print ' [PcdsDynamicExHii]' + print('PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections') + print(' [PcdsDynamicHii]') + print(' [PcdsDynamicExHii]') =20 # # Write PCD value or PCD statement to the output file @@ -189,4 +190,4 @@ if __name__ =3D=3D '__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/Script= s/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 IMP= LIED. # ## - +from __future__ import print_function import os import re import sys @@ -58,10 +58,10 @@ class Symbols: try: nmCommand =3D "nm" nmLineOption =3D "-l" - print "parsing (debug) - " + pdbName + print("parsing (debug) - " + pdbName) os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOp= tion, pdbName)) except : - print 'ERROR: nm command not available. Please verify PATH' + print('ERROR: nm command not available. Please verify PATH') return =20 # @@ -111,11 +111,11 @@ class Symbols: DIA2DumpCommand =3D "Dia2Dump.exe" #DIA2SymbolOption =3D "-p" DIA2LinesOption =3D "-l" - print "parsing (pdb) - " + pdbName + print("parsing (pdb) - " + pdbName) #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpComman= d, DIA2SymbolOption, pdbName)) os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, = DIA2LinesOption, pdbName)) except : - print 'ERROR: DIA2Dump command not available. Please verify P= ATH' + print('ERROR: DIA2Dump command not available. Please verify P= ATH') return =20 # @@ -254,12 +254,12 @@ def main(): try : file =3D open(Options.inputfilename) except Exception: - print "fail to open " + Options.inputfilename + print("fail to open " + Options.inputfilename) return 1 try : newfile =3D open(Options.outputfilename, "w") except Exception: - print "fail to open " + Options.outputfilename + print("fail to open " + Options.outputfilename) return 1 =20 try: diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py b/BaseTools/Sc= ripts/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 IMP= LIED. # ## - +from __future__ import print_function import os import re import sys @@ -61,10 +61,10 @@ class Symbols: try: nmCommand =3D "nm" nmLineOption =3D "-l" - print "parsing (debug) - " + pdbName + print("parsing (debug) - " + pdbName) os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOp= tion, pdbName)) except : - print 'ERROR: nm command not available. Please verify PATH' + print('ERROR: nm command not available. Please verify PATH') return =20 # @@ -103,11 +103,11 @@ class Symbols: DIA2DumpCommand =3D "Dia2Dump.exe" #DIA2SymbolOption =3D "-p" DIA2LinesOption =3D "-l" - print "parsing (pdb) - " + pdbName + print("parsing (pdb) - " + pdbName) #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpComman= d, DIA2SymbolOption, pdbName)) os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, = DIA2LinesOption, pdbName)) except : - print 'ERROR: DIA2Dump command not available. Please verify P= ATH' + print('ERROR: DIA2Dump command not available. Please verify P= ATH') return =20 # @@ -235,14 +235,14 @@ def main(): try : DOMTree =3D xml.dom.minidom.parse(Options.inputfilename) except Exception: - print "fail to open input " + Options.inputfilename + print("fail to open input " + Options.inputfilename) return 1 =20 if Options.guidreffilename is not None: try : guidreffile =3D 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(): =20 Handler =3D smiHandler.getElementsByTagName("Handler") RVA =3D Handler[0].getElementsByTagName("RVA") - print " Handler RVA: %s" % RVA[0].childNodes[0].data + print(" Handler RVA: %s" % RVA[0].childNodes[0].dat= a) =20 if (len(RVA)) >=3D 1: rvaName =3D RVA[0].childNodes[0].data @@ -289,7 +289,7 @@ def main(): =20 Caller =3D smiHandler.getElementsByTagName("Caller") RVA =3D Caller[0].getElementsByTagName("RVA") - print " Caller RVA: %s" % RVA[0].childNodes[0].data + print(" Caller RVA: %s" % RVA[0].childNodes[0].data) =20 if (len(RVA)) >=3D 1: rvaName =3D RVA[0].childNodes[0].data @@ -302,7 +302,7 @@ def main(): try : newfile =3D open(Options.outputfilename, "w") except Exception: - print "fail to open output" + Options.outputfilename + print("fail to open output" + Options.outputfilename) return 1 =20 newfile.write(DOMTree.toprettyxml(indent =3D "\t", newl =3D "\n", enco= ding =3D "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 @@ =20 ## 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=3Dfile) return True =20 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=3Dfile) =20 Module =3D property(_GetModule) Name =3D property(_GetBaseName) diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/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__ =3D=3D '__main__': EdkLogger.Initialize() if len(sys.argv) > 1: Br =3D 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])) =20 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)) =20 # 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/B= aseTools/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__ =3D=3D "__main__": test2 =3D TestObj(2) =20 testarr =3D [test1, test2] - print TestObj(2) in testarr - print TestObj(2) =3D=3D test2 + print(TestObj(2) in testarr) + print(TestObj(2) =3D=3D test2) =20 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]: " % VpdFile= Name + print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFile= Name) choice =3D sys.stdin.readline() if choice.strip().lower() not in ['y', 'yes', '']: return diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/S= ource/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 =3D self.Package for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'DecSpecification =3D', M.Header[Arch].DecSpecification - print '\nIncludes =3D', M.Includes + print('\nArch =3D', Arch) + print('Filename =3D', M.Header[Arch].FileName) + print('FullPath =3D', M.Header[Arch].FullPath) + print('BaseName =3D', M.Header[Arch].Name) + print('Guid =3D', M.Header[Arch].Guid) + print('Version =3D', M.Header[Arch].Version) + print('DecSpecification =3D', M.Header[Arch].DecSpecification) + print('\nIncludes =3D', M.Includes) for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nGuids =3D', M.GuidDeclarations + print(Item.FilePath, Item.SupArchList) + print('\nGuids =3D', M.GuidDeclarations) for Item in M.GuidDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nProtocols =3D', M.ProtocolDeclarations + print(Item.CName, Item.Guid, Item.SupArchList) + print('\nProtocols =3D', M.ProtocolDeclarations) for Item in M.ProtocolDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nPpis =3D', M.PpiDeclarations + print(Item.CName, Item.Guid, Item.SupArchList) + print('\nPpis =3D', M.PpiDeclarations) for Item in M.PpiDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nLibraryClasses =3D', M.LibraryClassDeclarations + print(Item.CName, Item.Guid, Item.SupArchList) + print('\nLibraryClasses =3D', M.LibraryClassDeclarations) for Item in M.LibraryClassDeclarations: - print Item.LibraryClass, Item.RecommendedInstance, Item.SupMod= uleList, Item.SupArchList - print '\nPcds =3D', M.PcdDeclarations + print(Item.LibraryClass, Item.RecommendedInstance, Item.SupMod= uleList, Item.SupArchList) + print('\nPcds =3D', M.PcdDeclarations) for Item in M.PcdDeclarations: - print 'CName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item.T= okenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', It= em.ItemType, 'Token=3D', Item.Token, 'DatumType=3D', Item.DatumType, Item.S= upArchList + print('CName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item.T= okenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', It= em.ItemType, 'Token=3D', Item.Token, 'DatumType=3D', Item.DatumType, Item.S= upArchList) =20 ## # diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Sourc= e/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 =3D Dict.keys() for Key in KeyList: if Dict[Key] !=3D '': - print Key + ' =3D ' + str(Dict[Key]) + print(Key + ' =3D ' + str(Dict[Key])) =20 ## Print the dictionary # @@ -71,6 +72,6 @@ def printList(Key, List): if type(List) =3D=3D type([]): if len(List) > 0: if Key.find(TAB_SPLIT) !=3D -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/S= ource/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) =20 for Key in self.KeyList: @@ -1382,47 +1383,47 @@ class Dsc(DscObject): def ShowPlatform(self): M =3D self.Platform for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'DscSpecification =3D', M.Header[Arch].DscSpecification - print 'SkuId =3D', M.Header[Arch].SkuIdName - print 'SupArchList =3D', M.Header[Arch].SupArchList - print 'BuildTargets =3D', M.Header[Arch].BuildTargets - print 'OutputDirectory =3D', M.Header[Arch].OutputDirectory - print 'BuildNumber =3D', M.Header[Arch].BuildNumber - print 'MakefileName =3D', M.Header[Arch].MakefileName - print 'BsBaseAddress =3D', M.Header[Arch].BsBaseAddress - print 'RtBaseAddress =3D', M.Header[Arch].RtBaseAddress - print 'Define =3D', M.Header[Arch].Define - print 'Fdf =3D', M.FlashDefinitionFile.FilePath - print '\nBuildOptions =3D', M.BuildOptions, M.BuildOptions.Include= Files + print('\nArch =3D', Arch) + print('Filename =3D', M.Header[Arch].FileName) + print('FullPath =3D', M.Header[Arch].FullPath) + print('BaseName =3D', M.Header[Arch].Name) + print('Guid =3D', M.Header[Arch].Guid) + print('Version =3D', M.Header[Arch].Version) + print('DscSpecification =3D', M.Header[Arch].DscSpecification) + print('SkuId =3D', M.Header[Arch].SkuIdName) + print('SupArchList =3D', M.Header[Arch].SupArchList) + print('BuildTargets =3D', M.Header[Arch].BuildTargets) + print('OutputDirectory =3D', M.Header[Arch].OutputDirectory) + print('BuildNumber =3D', M.Header[Arch].BuildNumber) + print('MakefileName =3D', M.Header[Arch].MakefileName) + print('BsBaseAddress =3D', M.Header[Arch].BsBaseAddress) + print('RtBaseAddress =3D', M.Header[Arch].RtBaseAddress) + print('Define =3D', M.Header[Arch].Define) + print('Fdf =3D', M.FlashDefinitionFile.FilePath) + print('\nBuildOptions =3D', M.BuildOptions, M.BuildOptions.Include= Files) for Item in M.BuildOptions.BuildOptionList: - print '\t', 'ToolChainFamily =3D', Item.ToolChainFamily, 'Tool= Chain =3D', Item.ToolChain, 'Option =3D', Item.Option, 'Arch =3D', Item.Sup= ArchList - print '\nSkuIds =3D', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFi= les - print '\nLibraries =3D', M.Libraries, M.Libraries.IncludeFiles + print('\t', 'ToolChainFamily =3D', Item.ToolChainFamily, 'Tool= Chain =3D', Item.ToolChain, 'Option =3D', Item.Option, 'Arch =3D', Item.Sup= ArchList) + print('\nSkuIds =3D', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFi= les) + print('\nLibraries =3D', M.Libraries, M.Libraries.IncludeFiles) for Item in M.Libraries.LibraryList: - print '\t', Item.FilePath, Item.SupArchList, Item.Define - print '\nLibraryClasses =3D', M.LibraryClasses, M.LibraryClasses.I= ncludeFiles + print('\t', Item.FilePath, Item.SupArchList, Item.Define) + print('\nLibraryClasses =3D', M.LibraryClasses, M.LibraryClasses.I= ncludeFiles) for Item in M.LibraryClasses.LibraryList: - print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item= .SupArchList, Item.Define - print '\nPcds =3D', M.DynamicPcdBuildDefinitions + print('\t', Item.Name, Item.FilePath, Item.SupModuleList, Item= .SupArchList, Item.Define) + print('\nPcds =3D', M.DynamicPcdBuildDefinitions) for Item in M.DynamicPcdBuildDefinitions: - print '\tCname=3D', Item.CName, 'TSG=3D', Item.TokenSpaceGuidC= Name, 'Value=3D', Item.DefaultValue, 'Token=3D', Item.Token, 'Type=3D', Ite= m.ItemType, 'Datum=3D', Item.DatumType, 'Size=3D', Item.MaxDatumSize, 'Arch= =3D', Item.SupArchList, Item.SkuInfoList + print('\tCname=3D', Item.CName, 'TSG=3D', Item.TokenSpaceGuidC= Name, 'Value=3D', Item.DefaultValue, 'Token=3D', Item.Token, 'Type=3D', Ite= m.ItemType, 'Datum=3D', Item.DatumType, 'Size=3D', Item.MaxDatumSize, 'Arch= =3D', Item.SupArchList, Item.SkuInfoList) for Sku in Item.SkuInfoList.values(): - print '\t\t', str(Sku) - print '\nComponents =3D', M.Modules.ModuleList, M.Modules.IncludeF= iles + print('\t\t', str(Sku)) + print('\nComponents =3D', M.Modules.ModuleList, M.Modules.IncludeF= iles) 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) =20 ## # diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/S= ource/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') =3D=3D None: - print 'ERROR: WORKSPACE not defined. Please run EdkSetup fr= om the EDK II install directory.' + print('ERROR: WORKSPACE not defined. Please run EdkSetup fr= om the EDK II install directory.') return False =20 self.CurrentWorkingDir =3D os.getcwd() @@ -76,18 +77,18 @@ class EdkIIWorkspace: if self.PrintRunTime: Seconds =3D int(time.time() - self.StartTime) if Seconds < 60: - print 'Run Time: %d seconds' % (Seconds) + print('Run Time: %d seconds' % (Seconds)) else: Minutes =3D Seconds / 60 Seconds =3D Seconds % 60 if Minutes < 60: - print 'Run Time: %d minutes %d seconds' % (Minutes, Se= conds) + print('Run Time: %d minutes %d seconds' % (Minutes, Se= conds)) else: Hours =3D Minutes / 60 Minutes =3D Minutes % 60 - print 'Run Time: %d hours %d minutes %d seconds' % (Ho= urs, Minutes, Seconds) + print('Run Time: %d hours %d minutes %d seconds' % (Ho= urs, Minutes, Seconds)) if self.RunStatus !=3D '': - print self.RunStatus + print(self.RunStatus) =20 ## 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)) =20 ## 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), SectionT= ag) =20 ## 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)) =20 ## Convert Text File To Dictionary @@ -182,7 +183,7 @@ class EdkIIWorkspace: # def ConvertTextFileToDictionary(self, FileName, Dictionary, CommentCha= racter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): if self.Verbose: - print FileName + print(FileName) return ConvertTextFileToDictionary(self.WorkspaceFile(FileName), D= ictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitC= haracter) =20 ## Convert Dictionary To Text File @@ -200,7 +201,7 @@ class EdkIIWorkspace: # def ConvertDictionaryToTextFile(self, FileName, Dictionary, CommentCha= racter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): if self.Verbose: - print FileName + print(FileName) return ConvertDictionaryToTextFile(self.WorkspaceFile(FileName), D= ictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitC= haracter) =20 ## Convert Text File To Dictionary @@ -317,4 +318,4 @@ def CreateFile(Directory, FileName, Mode=3D'w'): # if __name__ =3D=3D '__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/BaseTo= ols/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 =3D 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) =20 for Arch in self.SupArchList: - print Arch - print 'Platform' + print(Arch) + print('Platform') for Platform in self.Build[Arch].PlatformDatabase.keys(): P =3D self.Build[Arch].PlatformDatabase[Platform] - print 'DescFilePath =3D ', P.DescFilePath - print 'PlatformName =3D ', P.PlatformName - print 'Guid =3D ', P.Guid - print 'Version =3D ', P.Version - print 'OutputDirectory =3D ', P.OutputDirectory - print 'FlashDefinition =3D ', P.FlashDefinition - print 'SkuIds =3D ', P.SkuIds - print 'Modules =3D ', P.Modules - print 'LibraryClasses =3D ', P.LibraryClasses - print 'Pcds =3D ', P.Pcds + print('DescFilePath =3D ', P.DescFilePath) + print('PlatformName =3D ', P.PlatformName) + print('Guid =3D ', P.Guid) + print('Version =3D ', P.Version) + print('OutputDirectory =3D ', P.OutputDirectory) + print('FlashDefinition =3D ', P.FlashDefinition) + print('SkuIds =3D ', P.SkuIds) + print('Modules =3D ', P.Modules) + print('LibraryClasses =3D ', P.LibraryClasses) + print('Pcds =3D ', P.Pcds) for item in P.Pcds.keys(): - print P.Pcds[item] - print 'BuildOptions =3D ', P.BuildOptions - print '' + print(P.Pcds[item]) + print('BuildOptions =3D ', P.BuildOptions) + print('') # End of Platform =20 - print 'package' + print('package') for Package in self.Build[Arch].PackageDatabase.keys(): P =3D self.Build[Arch].PackageDatabase[Package] - print 'DescFilePath =3D ', P.DescFilePath - print 'PackageName =3D ', P.PackageName - print 'Guid =3D ', P.Guid - print 'Version =3D ', P.Version - print 'Protocols =3D ', P.Protocols - print 'Ppis =3D ', P.Ppis - print 'Guids =3D ', P.Guids - print 'Includes =3D ', P.Includes - print 'LibraryClasses =3D ', P.LibraryClasses - print 'Pcds =3D ', P.Pcds + print('DescFilePath =3D ', P.DescFilePath) + print('PackageName =3D ', P.PackageName) + print('Guid =3D ', P.Guid) + print('Version =3D ', P.Version) + print('Protocols =3D ', P.Protocols) + print('Ppis =3D ', P.Ppis) + print('Guids =3D ', P.Guids) + print('Includes =3D ', P.Includes) + print('LibraryClasses =3D ', P.LibraryClasses) + print('Pcds =3D ', P.Pcds) for item in P.Pcds.keys(): - print P.Pcds[item] - print '' + print(P.Pcds[item]) + print('') # End of Package =20 - print 'module' + print('module') for Module in self.Build[Arch].ModuleDatabase.keys(): P =3D self.Build[Arch].ModuleDatabase[Module] - print 'DescFilePath =3D ', P.DescFilePath - print 'BaseName =3D ', P.BaseName - print 'ModuleType =3D ', P.ModuleType - print 'Guid =3D ', P.Guid - print 'Version =3D ', P.Version - print 'CustomMakefile =3D ', P.CustomMakefile - print 'Specification =3D ', P.Specification - print 'Shadow =3D ', P.Shadow - print 'PcdIsDriver =3D ', P.PcdIsDriver + print('DescFilePath =3D ', P.DescFilePath) + print('BaseName =3D ', P.BaseName) + print('ModuleType =3D ', P.ModuleType) + print('Guid =3D ', P.Guid) + print('Version =3D ', P.Version) + print('CustomMakefile =3D ', P.CustomMakefile) + print('Specification =3D ', P.Specification) + print('Shadow =3D ', P.Shadow) + print('PcdIsDriver =3D ', P.PcdIsDriver) for Lib in P.LibraryClass: - print 'LibraryClassDefinition =3D ', Lib.LibraryClass,= 'SupModList =3D ', Lib.SupModList - print 'ModuleEntryPointList =3D ', P.ModuleEntryPointList - print 'ModuleUnloadImageList =3D ', P.ModuleUnloadImageList - print 'ConstructorList =3D ', P.ConstructorList - print 'DestructorList =3D ', P.DestructorList + print('LibraryClassDefinition =3D ', Lib.LibraryClass,= 'SupModList =3D ', Lib.SupModList) + print('ModuleEntryPointList =3D ', P.ModuleEntryPointList) + print('ModuleUnloadImageList =3D ', P.ModuleUnloadImageLis= t) + print('ConstructorList =3D ', P.ConstructorList) + print('DestructorList =3D ', P.DestructorList) =20 - print 'Binaries =3D ' + print('Binaries =3D ') for item in P.Binaries: - print item.BinaryFile, item.FeatureFlag, item.SupArchL= ist - print 'Sources =3D ' + print(item.BinaryFile, item.FeatureFlag, item.SupArchL= ist) + print('Sources =3D ') for item in P.Sources: - print item.SourceFile - print 'LibraryClasses =3D ', P.LibraryClasses - print 'Protocols =3D ', P.Protocols - print 'Ppis =3D ', P.Ppis - print 'Guids =3D ', P.Guids - print 'Includes =3D ', P.Includes - print 'Packages =3D ', P.Packages - print 'Pcds =3D ', P.Pcds + print(item.SourceFile) + print('LibraryClasses =3D ', P.LibraryClasses) + print('Protocols =3D ', P.Protocols) + print('Ppis =3D ', P.Ppis) + print('Guids =3D ', P.Guids) + print('Includes =3D ', P.Includes) + print('Packages =3D ', P.Packages) + print('Pcds =3D ', P.Pcds) for item in P.Pcds.keys(): - print P.Pcds[item] - print 'BuildOptions =3D ', P.BuildOptions - print 'Depex =3D ', P.Depex - print '' + print(P.Pcds[item]) + print('BuildOptions =3D ', P.BuildOptions) + print('Depex =3D ', P.Depex) + print('') # End of Module =20 ## @@ -1659,12 +1660,12 @@ class WorkspaceBuild(object): # script. # if __name__ =3D=3D '__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) =20 W =3D os.getenv('WORKSPACE') Ewb =3D WorkspaceBuild('Nt32Pkg/Nt32Pkg.dsc', W) Ewb.GenBuildDatabase({('PcdDevicePathSupportDevicePathFromText', 'gEfi= MdeModulePkgTokenSpaceGuid') : '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/Sourc= e/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 @@ =20 ## 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__ =3D=3D '__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/So= urce/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 =20 @@ -1269,8 +1270,8 @@ class FdfParser(object): self.__UndoToken() if not self.__IsToken("[FD.", True): FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) + print('Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ + % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine)) raise Warning("expected [FD.] At Line ", self.FileName, self.C= urrentLineNumber) =20 FdName =3D self.__GetUiName() @@ -1837,8 +1838,8 @@ class FdfParser(object): self.__UndoToken() if not self.__IsToken("[FV.", True): FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) + print('Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ + % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine)) raise Warning("Unknown Keyword At Line ", self.FileName, self.= CurrentLineNumber) =20 FvName =3D self.__GetUiName() @@ -2643,8 +2644,8 @@ class FdfParser(object): self.__UndoToken() if not self.__IsToken("[CAPSULE.", True): FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) + print('Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ + % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine)) raise Warning("expected [Capsule.] At Line ", self.FileName, s= elf.CurrentLineNumber) =20 =20 CapsuleObj =3D CommonDataClass.FdfClass.CapsuleClassObject() @@ -2766,8 +2767,8 @@ class FdfParser(object): self.__UndoToken() if not self.__IsToken("[Rule.", True): FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) + print('Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ + % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine)) raise Warning("expected [Rule.] At Line ", self.FileName, self= .CurrentLineNumber) =20 if not self.__SkipToToken("."): @@ -3357,8 +3358,8 @@ class FdfParser(object): self.__UndoToken() if not self.__IsToken("[VTF.", True): FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) + print('Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ + % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine)) raise Warning("expected [VTF.] At Line ", self.FileName, self.= CurrentLineNumber) =20 if not self.__SkipToToken("."): @@ -3650,7 +3651,7 @@ class FdfParser(object): raise Warning(LogStr) =20 except Warning: - print LogStr + print(LogStr) =20 finally: return CycleRefExists @@ -3660,7 +3661,7 @@ if __name__ =3D=3D "__main__": try: test_file =3D sys.argv[1] except IndexError as v: - print "Usage: %s filename" % sys.argv[0] + print("Usage: %s filename" % sys.argv[0]) sys.exit(1) =20 parser =3D FdfParser(test_file) @@ -3668,7 +3669,7 @@ if __name__ =3D=3D "__main__": parser.ParseFile() parser.CycleReferenceCheck() except Warning as X: - print X.message + print(X.message) else: - print "Success!" + print("Success!") =20 diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/S= ource/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 =3D self.Module for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'InfVersion =3D', M.Header[Arch].InfVersion - print 'UefiSpecificationVersion =3D', M.Header[Arch].UefiSpeci= ficationVersion - print 'EdkReleaseVersion =3D', M.Header[Arch].EdkReleaseVersion - print 'ModuleType =3D', M.Header[Arch].ModuleType - print 'BinaryModule =3D', M.Header[Arch].BinaryModule - print 'ComponentType =3D', M.Header[Arch].ComponentType - print 'MakefileName =3D', M.Header[Arch].MakefileName - print 'BuildNumber =3D', M.Header[Arch].BuildNumber - print 'BuildType =3D', M.Header[Arch].BuildType - print 'FfsExt =3D', M.Header[Arch].FfsExt - print 'FvExt =3D', M.Header[Arch].FvExt - print 'SourceFv =3D', M.Header[Arch].SourceFv - print 'PcdIsDriver =3D', M.Header[Arch].PcdIsDriver - print 'TianoEdkFlashMap_h =3D', M.Header[Arch].TianoEdkFlashMa= p_h - print 'Shadow =3D', M.Header[Arch].Shadow - print 'LibraryClass =3D', M.Header[Arch].LibraryClass + print('\nArch =3D', Arch) + print('Filename =3D', M.Header[Arch].FileName) + print('FullPath =3D', M.Header[Arch].FullPath) + print('BaseName =3D', M.Header[Arch].Name) + print('Guid =3D', M.Header[Arch].Guid) + print('Version =3D', M.Header[Arch].Version) + print('InfVersion =3D', M.Header[Arch].InfVersion) + print('UefiSpecificationVersion =3D', M.Header[Arch].UefiSpeci= ficationVersion) + print('EdkReleaseVersion =3D', M.Header[Arch].EdkReleaseVersio= n) + print('ModuleType =3D', M.Header[Arch].ModuleType) + print('BinaryModule =3D', M.Header[Arch].BinaryModule) + print('ComponentType =3D', M.Header[Arch].ComponentType) + print('MakefileName =3D', M.Header[Arch].MakefileName) + print('BuildNumber =3D', M.Header[Arch].BuildNumber) + print('BuildType =3D', M.Header[Arch].BuildType) + print('FfsExt =3D', M.Header[Arch].FfsExt) + print('FvExt =3D', M.Header[Arch].FvExt) + print('SourceFv =3D', M.Header[Arch].SourceFv) + print('PcdIsDriver =3D', M.Header[Arch].PcdIsDriver) + print('TianoEdkFlashMap_h =3D', M.Header[Arch].TianoEdkFlashMa= p_h) + print('Shadow =3D', M.Header[Arch].Shadow) + print('LibraryClass =3D', M.Header[Arch].LibraryClass) for Item in M.Header[Arch].LibraryClass: - print Item.LibraryClass, DataType.TAB_VALUE_SPLIT.join(Ite= m.SupModuleList) - print 'CustomMakefile =3D', M.Header[Arch].CustomMakefile - print 'Define =3D', M.Header[Arch].Define - print 'Specification =3D', M.Header[Arch].Specification + print(Item.LibraryClass, DataType.TAB_VALUE_SPLIT.join(Ite= m.SupModuleList)) + print('CustomMakefile =3D', M.Header[Arch].CustomMakefile) + print('Define =3D', M.Header[Arch].Define) + print('Specification =3D', M.Header[Arch].Specification) for Item in self.Module.ExternImages: - print '\nEntry_Point =3D %s, UnloadImage =3D %s' % (Item.Modul= eEntryPoint, Item.ModuleUnloadImage) + print('\nEntry_Point =3D %s, UnloadImage =3D %s' % (Item.Modul= eEntryPoint, Item.ModuleUnloadImage)) for Item in self.Module.ExternLibraries: - print 'Constructor =3D %s, Destructor =3D %s' % (Item.Construc= tor, Item.Destructor) - print '\nBuildOptions =3D', M.BuildOptions + print('Constructor =3D %s, Destructor =3D %s' % (Item.Construc= tor, Item.Destructor)) + print('\nBuildOptions =3D', M.BuildOptions) for Item in M.BuildOptions: - print Item.ToolChainFamily, Item.ToolChain, Item.Option, Item.= SupArchList - print '\nIncludes =3D', M.Includes + print(Item.ToolChainFamily, Item.ToolChain, Item.Option, Item.= SupArchList) + print('\nIncludes =3D', M.Includes) for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nLibraries =3D', M.Libraries + print(Item.FilePath, Item.SupArchList) + print('\nLibraries =3D', M.Libraries) for Item in M.Libraries: - print Item.Library, Item.SupArchList - print '\nLibraryClasses =3D', M.LibraryClasses + print(Item.Library, Item.SupArchList) + print('\nLibraryClasses =3D', M.LibraryClasses) for Item in M.LibraryClasses: - print Item.LibraryClass, Item.RecommendedInstance, Item.Featur= eFlag, Item.SupModuleList, Item.SupArchList, Item.Define - print '\nPackageDependencies =3D', M.PackageDependencies + print(Item.LibraryClass, Item.RecommendedInstance, Item.Featur= eFlag, Item.SupModuleList, Item.SupArchList, Item.Define) + print('\nPackageDependencies =3D', M.PackageDependencies) for Item in M.PackageDependencies: - print Item.FilePath, Item.SupArchList, Item.FeatureFlag - print '\nNmake =3D', M.Nmake + print(Item.FilePath, Item.SupArchList, Item.FeatureFlag) + print('\nNmake =3D', M.Nmake) for Item in M.Nmake: - print Item.Name, Item.Value, Item.SupArchList - print '\nPcds =3D', M.PcdCodes + print(Item.Name, Item.Value, Item.SupArchList) + print('\nPcds =3D', M.PcdCodes) for Item in M.PcdCodes: - print '\tCName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item= .TokenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', = Item.ItemType, Item.SupArchList - print '\nSources =3D', M.Sources + print('\tCName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item= .TokenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', = Item.ItemType, Item.SupArchList) + print('\nSources =3D', M.Sources) for Source in M.Sources: - print Source.SourceFile, 'Fam=3D', Source.ToolChainFamily, 'Pc= d=3D', Source.FeatureFlag, 'Tag=3D', Source.TagName, 'ToolCode=3D', Source.= ToolCode, Source.SupArchList - print '\nUserExtensions =3D', M.UserExtensions + print(Source.SourceFile, 'Fam=3D', Source.ToolChainFamily, 'Pc= d=3D', Source.FeatureFlag, 'Tag=3D', Source.TagName, 'ToolCode=3D', Source.= ToolCode, Source.SupArchList) + print('\nUserExtensions =3D', M.UserExtensions) for UserExtension in M.UserExtensions: - print UserExtension.UserID, UserExtension.Identifier, UserExte= nsion.Content - print '\nGuids =3D', M.Guids + print(UserExtension.UserID, UserExtension.Identifier, UserExte= nsion.Content) + print('\nGuids =3D', M.Guids) for Item in M.Guids: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nProtocols =3D', M.Protocols + print(Item.CName, Item.SupArchList, Item.FeatureFlag) + print('\nProtocols =3D', M.Protocols) for Item in M.Protocols: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nPpis =3D', M.Ppis + print(Item.CName, Item.SupArchList, Item.FeatureFlag) + print('\nPpis =3D', M.Ppis) for Item in M.Ppis: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nDepex =3D', M.Depex + print(Item.CName, Item.SupArchList, Item.FeatureFlag) + print('\nDepex =3D', M.Depex) for Item in M.Depex: - print Item.Depex, Item.SupArchList, Item.Define - print '\nBinaries =3D', M.Binaries + print(Item.Depex, Item.SupArchList, Item.Define) + print('\nBinaries =3D', M.Binaries) for Binary in M.Binaries: - print 'Type=3D', Binary.FileType, 'Target=3D', Binary.Target, = 'Name=3D', Binary.BinaryFile, 'FeatureFlag=3D', Binary.FeatureFlag, 'SupArc= hList=3D', Binary.SupArchList + print('Type=3D', Binary.FileType, 'Target=3D', Binary.Target, = 'Name=3D', Binary.BinaryFile, 'FeatureFlag=3D', Binary.FeatureFlag, 'SupArc= hList=3D', Binary.SupArchList) =20 ## 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 @@ =20 # # 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__() =20 def dump(self): - print "----------------------" + print("----------------------") rangelist =3D "" for object in self.rangelist: rangelist =3D rangelist + "[%d , %d]" % (object.start, object.= end) - print rangelist + print(rangelist) =20 =20 class XOROperatorObject(object): =20 diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseT= ools/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 =3D Dict.keys() for Key in KeyList: if Dict[Key] !=3D '': - print Key + ' =3D ' + str(Dict[Key]) + print(Key + ' =3D ' + str(Dict[Key])) =20 ## Print the dictionary # @@ -161,9 +162,9 @@ class TargetTxtClassObject(object): if type(List) =3D=3D type([]): if len(List) > 0: if Key.find(TAB_SPLIT) !=3D -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__ =3D=3D '__main__': pass Target =3D TargetTxtDict(os.getenv("WORKSPACE")) - print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRE= NT_THREAD_NUMBER] - print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET] - print Target.TargetTxtDictionary + print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRE= NT_THREAD_NUMBER]) + print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]) + print(Target.TargetTxtDictionary) diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/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 IMP= LIED. # +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= =3D"%s" % (str(X))) (out, error) =3D PopenObject.communicate() - print out + print(out) while PopenObject.returncode =3D=3D None : PopenObject.wait() =20 diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Pyth= on/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 =20 from antlr3 import * @@ -109,7 +110,7 @@ class CParser(Parser): =20 =20 def printTokenInfo(self, line, offset, tokenText): - print str(line)+ ',' + str(offset) + ':' + str(tokenText) + print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) =20 def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, StartO= ffset), (EndLine, EndOffset)) diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseToo= ls/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 # =20 +from __future__ import print_function import re import Common.LongFilePathOs as os import sys @@ -567,58 +568,58 @@ class CodeFragmentCollector: =20 def PrintFragments(self): =20 - print '################# ' + self.FileName + '####################= #' + print('################# ' + self.FileName + '####################= #') =20 - 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) =20 - 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) =20 - 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) =20 - print '/****************************************/' - print '/********* FUNCTION DEFINITIONS *********/' - print '/****************************************/' + print('/****************************************/') + print('/********* FUNCTION DEFINITIONS *********/') + print('/****************************************/') for func in FileProfile.FunctionDefinitionList: - print str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos) + print(str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos)) =20 - 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) =20 - 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) =20 - 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) =20 - print '/****************************************/' =20 - print '/************** TYPEDEFS ****************/' - print '/****************************************/' + print('/****************************************/') + print('/************** TYPEDEFS ****************/') + print('/****************************************/') for typedef in FileProfile.TypedefDefinitionList: - print str(typedef.StartPos) + typedef.ToType + print(str(typedef.StartPos) + typedef.ToType) =20 if __name__ =3D=3D "__main__": =20 collector =3D CodeFragmentCollector(sys.argv[1]) collector.PreprocessFile() - print "For Test." + print("For Test.") diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Sourc= e/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]] =3D List[1] =20 def ShowMe(self): - print self.Filename + print(self.Filename) for Key in self.__dict__.keys(): - print Key, '=3D', self.__dict__[Key] + print(Key, '=3D', self.__dict__[Key]) diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Py= thon/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 =20 @@ -84,4 +85,4 @@ class ExceptionCheck(object): # if __name__ =3D=3D '__main__': El =3D ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\excepti= on.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 =20 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]) =20 ## Get count # diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Sou= rce/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 =20 @@ -215,7 +216,7 @@ def XmlParseFile(FileName): XmlFile.close() return Dom except Exception as X: - print X + print(X) return "" =20 # This acts like the main() function for the script, unless it is 'import'= ed @@ -225,5 +226,5 @@ if __name__ =3D=3D '__main__': A =3D CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']]= , [['A', '1'], ['B', '2']]) B =3D CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']]= , [['A', '1'], ['B', '2']]) C =3D CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG']) - print C.toprettyxml(indent =3D " ") + print(C.toprettyxml(indent =3D " ")) 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 IMP= LIED. # =20 +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) =20 =20 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) =20 # Func Decl check SqlStatement =3D """ 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) =20 SqlStatement =3D """ select Modifier, Header, StartLine, ID, Name from Function @@ -2628,9 +2629,9 @@ if __name__ =3D=3D '__main__': try: test_file =3D 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 =3D 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/Pyth= on/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 =20 from antlr3 import * @@ -109,7 +110,7 @@ class CParser(Parser): =20 =20 def printTokenInfo(self, line, offset, tokenText): - print str(line)+ ',' + str(offset) + ':' + str(tokenText) + print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) =20 def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, StartO= ffset), (EndLine, EndOffset)) diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseToo= ls/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): =20 - print '################# ' + self.FileName + '####################= #' + print('################# ' + self.FileName + '####################= #') =20 - print '/****************************************/' - print '/*************** ASSIGNMENTS ***************/' - print '/****************************************/' + print('/****************************************/') + print('/*************** ASSIGNMENTS ***************/') + print('/****************************************/') for asign in FileProfile.AssignmentExpressionList: - print str(asign.StartPos) + asign.Name + asign.Operator + asig= n.Value + print(str(asign.StartPos) + asign.Name + asign.Operator + asig= n.Value) =20 - 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) =20 - 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) =20 - print '/****************************************/' - print '/********* FUNCTION DEFINITIONS *********/' - print '/****************************************/' + print('/****************************************/') + print('/********* FUNCTION DEFINITIONS *********/') + print('/****************************************/') for func in FileProfile.FunctionDefinitionList: - print str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos) + print(str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos)) =20 - 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) =20 - 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) =20 - 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) =20 ## # @@ -464,4 +465,4 @@ class CodeFragmentCollector: # if __name__ =3D=3D "__main__": =20 - print "For Test." + print("For Test.") diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Pyth= on/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 @@ =20 ## 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 =3D= \ self._FileHeader.unpack_from(self._PeImageBuf, self.Offset + F= ileHeaderOffset) =20 - print "Machine=3D%x NumberOfSections=3D%x SizeOfOptionalHeader=3D%= x" % (self.Machine, self.NumberOfSections, self.SizeOfOptionalHeader) + print("Machine=3D%x NumberOfSections=3D%x SizeOfOptionalHeader=3D%= x" % (self.Machine, self.NumberOfSections, self.SizeOfOptionalHeader)) # optional header follows the FILE header OptionalHeaderOffset =3D FileHeaderOffset + struct.calcsize(self._= FileHeaderFormat) Magic, self.SizeOfImage, SizeOfHeaders, self.Checksum, NumberOfRva= AndSizes =3D \ self._OptionalHeader32.unpack_from(self._PeImageBuf, self.Offs= et + OptionalHeaderOffset) - print "Magic=3D%x SizeOfImage=3D%x SizeOfHeaders=3D%x, Checksum=3D= %x, NumberOfRvaAndSizes=3D%x" % (Magic, self.SizeOfImage, SizeOfHeaders, se= lf.Checksum, NumberOfRvaAndSizes) + print("Magic=3D%x SizeOfImage=3D%x SizeOfHeaders=3D%x, Checksum=3D= %x, NumberOfRvaAndSizes=3D%x" % (Magic, self.SizeOfImage, SizeOfHeaders, se= lf.Checksum, NumberOfRvaAndSizes)) =20 PeImageSectionTableOffset =3D OptionalHeaderOffset + self.SizeOfOp= tionalHeader PeSections =3D PeSectionTable(self._PeImageBuf, self.Offset + PeIm= ageSectionTableOffset, self.NumberOfSections) =20 - print "%x" % PeSections.GetFileAddress(0x3920) + print("%x" % PeSections.GetFileAddress(0x3920)) =20 ## PeSectionTable() class # @@ -1215,7 +1216,7 @@ class PeSectionTable: SectionHeader =3D PeSectionHeader(Buf, SectionHeaderOffset) self._SectionList.append(SectionHeader) SectionHeaderOffset +=3D len(SectionHeader) - print SectionHeader + print(SectionHeader) =20 def GetFileAddress(self, Rva): for PeSection in self._SectionList: @@ -1412,7 +1413,7 @@ def Main(): Option =3D GetOptions() build.main() except Exception as e: - print e + print(e) return 1 =20 return 0 @@ -1435,7 +1436,7 @@ if __name__ =3D=3D '__main__': fv =3D FirmwareVolume("FVRECOVERY") fv.frombuffer(buf, 0, len(buf)) #fv.Dispatch(None) - print fv + print(fv) elif FilePath.endswith(".efi"): fd =3D open(FilePath, 'rb') buf =3D array('B') diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Sourc= e/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__ =3D=3D '__main__': Db.InitDatabase() P =3D 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]) =20 - 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__ =3D=3D '__main__': EdkLogger.SetLevel(EdkLogger.QUIET) CollectSourceCodeDataIntoDB(sys.argv[1]) =20 - 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 =20 import Fd @@ -4818,7 +4819,7 @@ if __name__ =3D=3D "__main__": try: test_file =3D sys.argv[1] except IndexError as v: - print "Usage: %s filename" % sys.argv[0] + print("Usage: %s filename" % sys.argv[0]) sys.exit(1) =20 parser =3D FdfParser(test_file) @@ -4826,7 +4827,7 @@ if __name__ =3D=3D "__main__": parser.ParseFile() parser.CycleReferenceCheck() except Warning as X: - print str(X) + print(str(X)) else: - print "Success!" + print("Success!") =20 diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/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 =3D BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobal= Variable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules for Key in ModuleDict: ModuleObj =3D BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag] - print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType + print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType) =20 def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj): GuidXRefFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, "Gui= d.xref") diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/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 !=3D 0: - print "###", cmd + print("###", cmd) EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess) =20 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 @@ # =20 #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D External Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +from __future__ import print_function import optparse import Common.LongFilePathOs as os import re @@ -215,7 +216,7 @@ if __name__ =3D=3D '__main__': (options, args) =3D parser.parse_args() =20 if options.mapfile =3D=3D None or options.efifile =3D=3D None: - print parser.get_usage() + print(parser.get_usage()) elif os.path.exists(options.mapfile) and os.path.exists(options.efifil= e): list =3D parsePcdInfoFromMapFile(options.mapfile, options.efifile) if list !=3D None: @@ -224,6 +225,6 @@ if __name__ =3D=3D '__main__': else: generatePcdTable(list, options.mapfile.replace('.map', '.B= inaryPcdTable.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/Sou= rce/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 =20 import os import sys @@ -113,14 +114,14 @@ if __name__ =3D=3D '__main__': try: Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) except: - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(1) =20 Version =3D Process.communicate() if Process.returncode <> 0: - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) - print Version[0] + print(Version[0]) =20 # # Read input file into a buffer and save input filename @@ -134,7 +135,7 @@ if __name__ =3D=3D '__main__': # OutputDir =3D 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 =3D args.OutputFile =20 @@ -170,7 +171,7 @@ if __name__ =3D=3D '__main__': args.SignerPrivateCertFile =3D open(args.SignerPrivateCertFileName= , 'rb') args.SignerPrivateCertFile.close() except: - print 'ERROR: test signer private cert file %s missing' % (args.Si= gnerPrivateCertFileName) + print('ERROR: test signer private cert file %s missing' % (args.Si= gnerPrivateCertFileName)) sys.exit(1) =20 # @@ -196,7 +197,7 @@ if __name__ =3D=3D '__main__': args.OtherPublicCertFile =3D open(args.OtherPublicCertFileName, 'r= b') args.OtherPublicCertFile.close() except: - print 'ERROR: test other public cert file %s missing' % (args.Othe= rPublicCertFileName) + print('ERROR: test other public cert file %s missing' % (args.Othe= rPublicCertFileName)) sys.exit(1) =20 format =3D "%dsQ" % len(args.InputFileBuffer) @@ -242,11 +243,11 @@ if __name__ =3D=3D '__main__': args.TrustedPublicCertFile =3D open(args.TrustedPublicCertFileName= , 'rb') args.TrustedPublicCertFile.close() except: - print 'ERROR: test trusted public cert file %s missing' % (args.Tr= ustedPublicCertFileName) + print('ERROR: test trusted public cert file %s missing' % (args.Tr= ustedPublicCertFileName)) sys.exit(1) =20 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__ =3D=3D '__main__': else: SignatureSize =3D (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 s= ize of the input file !" + print("ERROR: The value of option --signature-size is exceed the s= ize of the input file !") sys.exit(1) =20 args.SignatureBuffer =3D args.InputFileBuffer[0:SignatureSize] @@ -277,7 +278,7 @@ if __name__ =3D=3D '__main__': Process =3D subprocess.Popen('%s smime -verify -inform DER -content %s= -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCert= FileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) Process.communicate(input=3Dargs.SignatureBuffer)[0] if Process.returncode <> 0: - print 'ERROR: Verification failed' + print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) =20 diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.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 =20 import os import sys @@ -75,14 +76,14 @@ if __name__ =3D=3D '__main__': try: Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) except: =20 - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(1) =20 Version =3D Process.communicate() if Process.returncode <> 0: - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) - print Version[0] + print(Version[0]) =20 args.PemFileName =3D [] =20 @@ -103,7 +104,7 @@ if __name__ =3D=3D '__main__': Process =3D subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslComm= and, Item.name), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) Process.communicate() if Process.returncode <> 0: - print 'ERROR: RSA 2048 key generation failed' + print('ERROR: RSA 2048 key generation failed') sys.exit(Process.returncode) =20 # @@ -125,7 +126,7 @@ if __name__ =3D=3D '__main__': Process =3D subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSs= lCommand, Item), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) PublicKeyHexString =3D Process.communicate()[0].split('=3D')[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 =3D '' for Index in range (0, len(PublicKeyHexString), 2): @@ -138,7 +139,7 @@ if __name__ =3D=3D '__main__': Process.stdin.write (PublicKey) PublicKeyHash =3D 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) =20 # @@ -171,4 +172,4 @@ if __name__ =3D=3D '__main__': # If verbose is enabled display the public key in C structure format # if args.Verbose: - print 'PublicKeySha256 =3D ' + PublicKeyHashC =20 + print('PublicKeySha256 =3D ' + 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 =20 import os import sys @@ -96,14 +97,14 @@ if __name__ =3D=3D '__main__': try: Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) except: =20 - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(1) =20 Version =3D Process.communicate() if Process.returncode <> 0: - print 'ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) - print Version[0] + print(Version[0]) =20 # # Read input file into a buffer and save input filename @@ -117,7 +118,7 @@ if __name__ =3D=3D '__main__': # OutputDir =3D 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 =3D args.OutputFile =20 @@ -144,7 +145,7 @@ if __name__ =3D=3D '__main__': args.PrivateKeyFile =3D open(args.PrivateKeyFileName, 'rb') args.PrivateKeyFile.close() except: - print 'ERROR: test signing private key file %s missing' % (args.Priv= ateKeyFileName) + print('ERROR: test signing private key file %s missing' % (args.Priv= ateKeyFileName)) sys.exit(1) =20 # @@ -202,14 +203,14 @@ if __name__ =3D=3D '__main__': # Verify that the Hash Type matches the expected SHA256 type # if uuid.UUID(bytes_le =3D Header.HashType) <> EFI_HASH_ALGORITHM_SHA25= 6_GUID: - print 'ERROR: unsupport hash GUID' + print('ERROR: unsupport hash GUID') sys.exit(1) =20 # # Verify the public key # if Header.PublicKey <> PublicKey: - print 'ERROR: Public key in input file does not match public key fro= m private key file' + print('ERROR: Public key in input file does not match public key fro= m private key file') sys.exit(1) =20 FullInputFileBuffer =3D args.InputFileBuffer @@ -228,7 +229,7 @@ if __name__ =3D=3D '__main__': Process =3D subprocess.Popen('%s sha256 -prverify "%s" -signature %s' = % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=3Ds= ubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) Process.communicate(input=3DFullInputFileBuffer) if Process.returncode <> 0: - print 'ERROR: Verification failed' + print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) =20 diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/S= ource/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 IM= PLIED. # =20 +from __future__ import print_function import Common.LongFilePathOs as os import sys import traceback @@ -32,7 +33,7 @@ class TargetTool(): self.Arg =3D args[0] self.FileName =3D os.path.normpath(os.path.join(self.WorkSpace, '= Conf', 'target.txt')) if os.path.isfile(self.FileName) =3D=3D False: - print "%s does not exist." % self.FileName + print("%s does not exist." % self.FileName) sys.exit(1) self.TargetTxtDictionary =3D { TAB_TAT_DEFINES_ACTIVE_PLATFORM : N= one, @@ -84,14 +85,14 @@ class TargetTool(): errMsg =3D '' for Key in KeyList: if type(self.TargetTxtDictionary[Key]) =3D=3D type([]): - print "%-30s =3D %s" % (Key, ''.join(elem + ' ' for elem i= n self.TargetTxtDictionary[Key])) + print("%-30s =3D %s" % (Key, ''.join(elem + ' ' for elem i= n self.TargetTxtDictionary[Key]))) elif self.TargetTxtDictionary[Key] =3D=3D None: errMsg +=3D " Missing %s configuration information, pleas= e use TargetTool to set value!" % Key + os.linesep=20 else: - print "%-30s =3D %s" % (Key, self.TargetTxtDictionary[Key]) + print("%-30s =3D %s" % (Key, self.TargetTxtDictionary[Key]= )) =20 if errMsg !=3D '': - print os.linesep + 'Warning:' + os.linesep + errMsg + print(os.linesep + 'Warning:' + os.linesep + errMsg) =20 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 i= n original configuration files!" + print("Warning: Found duplicate key item i= n original configuration files!") =20 if Num =3D=3D 0: Line =3D "%-30s =3D \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 configur= ation file" % key + print("Warning: %s does not exist in original configur= ation file" % key) Line =3D GetConfigureKeyValue(self, key) if Line =3D=3D None: Line =3D "%-30s =3D " % key @@ -224,25 +225,25 @@ if __name__ =3D=3D '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.QUIET) if os.getenv('WORKSPACE') =3D=3D None: - print "ERROR: WORKSPACE should be specified or edksetup script sho= uld be executed before run TargetTool" + print("ERROR: WORKSPACE should be specified or edksetup script sho= uld be executed before run TargetTool") sys.exit(1) =20 (opt, args) =3D MyOptionParser() if len(args) !=3D 1 or (args[0].lower() !=3D 'print' and args[0].lower= () !=3D 'clean' and args[0].lower() !=3D '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 !=3D 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 !=3D None and len(opt.TARGET) > 1: for elem in opt.TARGET: if elem =3D=3D '0': - print "0 will clear the TARGET setting in target.txt and c= an't combine with other value." + print("0 will clear the TARGET setting in target.txt and c= an't combine with other value.") sys.exit(1) if opt.TARGET_ARCH !=3D None and len(opt.TARGET_ARCH) > 1: for elem in opt.TARGET_ARCH: if elem =3D=3D '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) =20 try: diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/Ba= seTools/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 =20 ## # Import Modules @@ -566,7 +567,7 @@ def IsValidFeatureFlagExp(Token, Flag=3DFalse): =20 if __name__ =3D=3D '__main__': # print IsValidRangeExpr('LT 9') - print _LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1B= ridgeAddressLE0').IsValidLogicalExpression() + print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1B= ridgeAddressLE0').IsValidLogicalExpression()) =20 =20 =20 diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTo= ols/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 =20 ## # Import Modules @@ -748,7 +749,7 @@ class UniFileClassObject(object): EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) NewLines.append(Line) else: - print Line + print(Line) EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, ExtraData=3DFile.Path) =20 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)) =20 # # Read content from '!include' UNI file=20 diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/Ba= seTools/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 =20 ## # Import Modules @@ -902,47 +903,47 @@ class DecPomAlignment(PackageObject): # Print all members and their values of Package class # def ShowPackage(self): - print '\nName =3D', self.GetName() - print '\nBaseName =3D', self.GetBaseName() - print '\nVersion =3D', self.GetVersion()=20 - print '\nGuid =3D', self.GetGuid() + print('\nName =3D', self.GetName()) + print('\nBaseName =3D', self.GetBaseName()) + print('\nVersion =3D', self.GetVersion()) + print('\nGuid =3D', self.GetGuid()) =20 - print '\nStandardIncludes =3D %d ' \ - % len(self.GetStandardIncludeFileList()), + print('\nStandardIncludes =3D %d ' \ + % len(self.GetStandardIncludeFileList()), end=3D' ') for Item in self.GetStandardIncludeFileList(): - print Item.GetFilePath(), ' ', Item.GetSupArchList() - print '\nPackageIncludes =3D %d \n' \ - % len(self.GetPackageIncludeFileList()), + print(Item.GetFilePath(), ' ', Item.GetSupArchList()) + print('\nPackageIncludes =3D %d \n' \ + % len(self.GetPackageIncludeFileList()), end=3D' ') for Item in self.GetPackageIncludeFileList(): - print Item.GetFilePath(), ' ', Item.GetSupArchList() + print(Item.GetFilePath(), ' ', Item.GetSupArchList()) =20 - print '\nGuids =3D', self.GetGuidList() + print('\nGuids =3D', self.GetGuidList()) for Item in self.GetGuidList(): - print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList() - print '\nProtocols =3D', self.GetProtocolList() + print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()) + print('\nProtocols =3D', self.GetProtocolList()) for Item in self.GetProtocolList(): - print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList() - print '\nPpis =3D', self.GetPpiList() + print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()) + print('\nPpis =3D', self.GetPpiList()) for Item in self.GetPpiList(): - print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList() - print '\nLibraryClasses =3D', self.GetLibraryClassList() + print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()) + print('\nLibraryClasses =3D', self.GetLibraryClassList()) for Item in self.GetLibraryClassList(): - print Item.GetLibraryClass(), Item.GetRecommendedInstance(), \ - Item.GetSupArchList() - print '\nPcds =3D', self.GetPcdList() + print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \ + Item.GetSupArchList()) + print('\nPcds =3D', self.GetPcdList()) for Item in self.GetPcdList(): - print 'CName=3D', Item.GetCName(), 'TokenSpaceGuidCName=3D', \ + print('CName=3D', Item.GetCName(), 'TokenSpaceGuidCName=3D', \ Item.GetTokenSpaceGuidCName(), \ 'DefaultValue=3D', Item.GetDefaultValue(), \ 'ValidUsage=3D', Item.GetValidUsage(), \ 'SupArchList', Item.GetSupArchList(), \ - 'Token=3D', Item.GetToken(), 'DatumType=3D', Item.GetDatum= Type() + 'Token=3D', Item.GetToken(), 'DatumType=3D', Item.GetDatum= Type()) =20 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') =20 ## GenPcdDeclaration # diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py b/BaseTo= ols/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 IMP= LIED. =20 +from __future__ import print_function import os import unittest =20 @@ -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) =20 # Call test function to test @@ -279,6 +280,6 @@ if __name__ =3D=3D '__main__': unittest.FunctionTestCase(TestDecPcd).runTest() unittest.FunctionTestCase(TestDecUserExtension).runTest() =20 - print 'All tests passed...' + print('All tests passed...') =20 =20 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 IMP= LIED. =20 +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 =3D open (FileName, "w") =20 TempFile.close() except: - print "File Create Error" + print("File Create Error") CurrentLine =3D CurrentLine() CurrentLine.SetFileName("Test") CurrentLine.SetLineString(Item[0]) @@ -376,11 +377,11 @@ if __name__ =3D=3D '__main__': try: InfBinariesInstance.SetBinary(Ver =3D Ver, ArchList =3D Ar= chList) except: - print "Test Failed!" + print("Test Failed!") AllPassedFlag =3D False =20 if AllPassedFlag : - print 'All tests passed...' + print('All tests passed...') else: - print 'Some unit test failed!' + print('Some unit test failed!') =20 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 conve= rt 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_DYNAMI= C_HII],self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]): for storename in pcdobj.SkuInfoList[skuid].DefaultStor= eDict: - print "PcdCName: %s, SkuName: %s, StoreName: %s, V= alue: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), sku= id,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename])) + print("PcdCName: %s, SkuName: %s, StoreName: %s, V= alue: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), sku= id,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename]))) else: - print "PcdCName: %s, SkuName: %s, Value: %s" % (".".jo= in((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuIn= foList[skuid].DefaultValue)) + print("PcdCName: %s, SkuName: %s, Value: %s" % (".".jo= in((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuIn= foList[skuid].DefaultValue))) ## Retrieve [BuildOptions] def _GetBuildOptions(self): if self._BuildOptions =3D=3D None: @@ -1067,7 +1068,7 @@ class DscBuildData(PlatformBuildClassObject): for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Va= lues: str_pcd_obj =3D 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_D= YNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX_HII]]: @@ -1244,10 +1245,10 @@ class DscBuildData(PlatformBuildClassObject): if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': return True if Value.startswith("L'") and Value.endswith("'") and len(list(Val= ue[2:-1])) > 1: - print 'foo =3D ', list(Value[2:-1]) + print('foo =3D ', list(Value[2:-1])) return True if Value[0] =3D=3D "'" and Value[-1] =3D=3D "'" and len(list(Value= [1:-1])) > 1: - print 'bar =3D ', list(Value[1:-1]) + print('bar =3D ', list(Value[1:-1])) return True return False =20 @@ -1255,11 +1256,11 @@ class DscBuildData(PlatformBuildClassObject): try: Process =3D subprocess.Popen(Command, stdout=3Dsubprocess.PIPE= , stderr=3Dsubprocess.PIPE, shell=3DTrue) except: - print 'ERROR: Can not execute command:', Command + print('ERROR: Can not execute command:', Command) sys.exit(1) Result =3D 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] =20 def IntToCString(self, Value, ValueSize): @@ -1376,7 +1377,7 @@ class DscBuildData(PlatformBuildClassObject): try: Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0]) except Exception: - print FieldList[FieldName][0] + print(FieldList[FieldName][0]) if isinstance(Value, str): CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) elif IsArray: @@ -1414,7 +1415,7 @@ class DscBuildData(PlatformBuildClassObject): try: Value, ValueSize =3D ParseFieldValue (FieldLis= t[FieldName][0]) except Exception: - print FieldList[FieldName][0] + print(FieldList[FieldName][0]) if isinstance(Value, str): CApp =3D CApp + ' Pcd->%s =3D %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/BaseTool= s/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] =3D '|'.join(ValList) except Exception: - print ValList + print(ValList) =20 def __ProcessComponent(self): self._ValueList[0] =3D ReplaceMacro(self._ValueList[0], self._Macr= os) diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/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 =3D os.path.join(FvDir, 'GuidedSectionTools.= txt') toolsFile =3D open(toolsFile, 'wt') for guidedSectionTool in guidAttribs: - print >> toolsFile, ' '.join(guidedSectionTool) + print(' '.join(guidedSectionTool), file=3DtoolsFil= e) toolsFile.close() =20 ## 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) =20 def DisplayBinaryData(self, description, data): - print description, '(base64 encoded):' + print(description, '(base64 encoded):') b64data =3D base64.b64encode(data) - print b64data + print(b64data) =20 def DisplayFile(self, fileName): sys.stdout.write(self.ReadTmpFile(fileName)) diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompre= ss.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 =3D self.ReadTmpFile('output2') startEqualsFinish =3D start =3D=3D 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-bui= ld.py index 858b4020ef9f..643fec58a457 100755 --- a/BaseTools/gcc/mingw-gcc-build.py +++ b/BaseTools/gcc/mingw-gcc-build.py @@ -17,6 +17,7 @@ # =20 =20 +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) =20 # @@ -146,37 +147,37 @@ class Config: if not self.options.skip_gcc: building.append('gcc') if len(building) =3D=3D 0: - print "Nothing will be built!" - print - print "Please try using --help and then change the configurati= on." + print("Nothing will be built!") + print() + print("Please try using --help and then change the configurati= on.") return False =20 - 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 =3D raw_input("Is this configuration ok? (default =3D no): = ") if (answer.lower() not in ('y', 'yes')): - print - print "Please try using --help and then change the configurati= on." + print() + print("Please try using --help and then change the configurati= on.") return False =20 if self.arch.lower() =3D=3D '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 =3D raw_input("Are you sure you want to build it? (defa= ult =3D no): ") if (answer.lower() not in ('y', 'yes')): - print - print "Please try using --help and then change the configu= ration." + print() + print("Please try using --help and then change the configu= ration.") return False =20 - print + print() return True =20 def Relative(self, path): @@ -275,7 +276,7 @@ class SourceFiles: wDots =3D (100 * received * blockSize) / fileSize / 10 if wDots > self.dots: for i in range(wDots - self.dots): - print '.', + print('.', end=3D' ') sys.stdout.flush() self.dots +=3D 1 =20 @@ -286,18 +287,18 @@ class SourceFiles: self.dots =3D 0 local_file =3D os.path.join(self.config.src_dir, fdata= ['filename']) url =3D fdata['url'] - print 'Downloading %s:' % fname, url + print('Downloading %s:' % fname, url) if retries > 0: - print '(retry)', + print('(retry)', end=3D' ') sys.stdout.flush() =20 completed =3D False if os.path.exists(local_file): md5_pass =3D self.checkHash(fdata) if md5_pass: - print '[md5 match]', + print('[md5 match]', end=3D' ') else: - print '[md5 mismatch]', + print('[md5 mismatch]', end=3D' ') sys.stdout.flush() completed =3D md5_pass =20 @@ -313,32 +314,32 @@ class SourceFiles: if not completed and os.path.exists(local_file): md5_pass =3D self.checkHash(fdata) if md5_pass: - print '[md5 match]', + print('[md5 match]', end=3D' ') else: - print '[md5 mismatch]', + print('[md5 mismatch]', end=3D' ') sys.stdout.flush() completed =3D md5_pass =20 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 settin= g the', - print 'http_proxy environment variable' - print '* You can try to download this file separat= ely', - 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 settin= g the', end=3D' ') + print('http_proxy environment variable') + print('* You can try to download this file separat= ely', end=3D' ') + print('and rerun this script') raise Exception() =20 except KeyboardInterrupt: - print '[KeyboardInterrupt]' + print('[KeyboardInterrupt]') return False =20 except Exception as e: - print e + print(e) =20 if not completed: return False =20 @@ -396,7 +397,7 @@ class Extracter: extractedMd5 =3D open(extracted).read() =20 if extractedMd5 !=3D moduleMd5: - print 'Extracting %s:' % self.config.Relative(local_file) + print('Extracting %s:' % self.config.Relative(local_file)) tar =3D tarfile.open(local_file) tar.extractall(extractDst) open(extracted, 'w').write(moduleMd5) @@ -480,7 +481,7 @@ class Builder: =20 os.chdir(base_dir) =20 - print '%s module is now built and installed' % module + print('%s module is now built and installed' % module) =20 def RunCommand(self, cmd, module, stage, skipable=3DFalse): if skipable: @@ -495,13 +496,13 @@ class Builder: stderr=3Dsubprocess.STDOUT ) =20 - print '%s [%s] ...' % (module, stage), + print('%s [%s] ...' % (module, stage), end=3D' ') sys.stdout.flush() p =3D popen(cmd) output =3D p.stdout.read() p.wait() if p.returncode !=3D 0: - print '[failed!]' + print('[failed!]') logFile =3D os.path.join(self.config.build_dir, 'log.txt') f =3D 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]') =20 if skipable: self.MarkBuildStepComplete('%s.%s' % (module, stage)) @@ -526,13 +527,13 @@ class Builder: linkdst =3D 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=3D' ') startPrinted =3D True - print link, + print(link, end=3D' ') os.symlink(src, linkdst) =20 if startPrinted: - print '[done]' + print('[done]') =20 class App: """class App @@ -551,9 +552,9 @@ class App: sources =3D SourceFiles(config) result =3D 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 =20 Extracter(sources, config).ExtractAll() --=20 2.15.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel