From nobody Sun Sep 7 12:24:20 2025 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 1529556268236813.037912794459; Wed, 20 Jun 2018 21:44:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 065F1211D5062; Wed, 20 Jun 2018 21:44:23 -0700 (PDT) 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 D1ED7211D505F for ; Wed, 20 Jun 2018 21:44:20 -0700 (PDT) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Thu, 21 Jun 2018 06:44:17 +0200 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: Thu, 21 Jun 2018 12:43:29 +0800 Message-Id: <20180621044346.28495-4-glin@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621044346.28495-1-glin@suse.com> References: <20180621044346.28495-1-glin@suse.com> Subject: [edk2] [PATCH v3 03/20] BaseTools: Refactor python print statements X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 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 = | 1 + BaseTools/Scripts/FormatDosFiles.py = | 1 + BaseTools/Scripts/MemoryProfileSymbolGen.py = | 13 +-- BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py = | 47 +++++----- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxyge= n.py | 3 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibin= ary.py | 29 +++--- BaseTools/Scripts/SmiHandlerProfileSymbolGen.py = | 19 ++-- BaseTools/Source/Python/AutoGen/AutoGen.py = | 5 +- BaseTools/Source/Python/AutoGen/BuildEngine.py = | 31 +++--- BaseTools/Source/Python/AutoGen/UniClassObject.py = | 7 +- BaseTools/Source/Python/BPDG/BPDG.py = | 3 +- BaseTools/Source/Python/Common/Expression.py = | 11 ++- BaseTools/Source/Python/Common/RangeExpression.py = | 5 +- BaseTools/Source/Python/Common/TargetTxtClassObject.py = | 7 +- 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/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 = | 5 +- 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 ++++++++++---------- 46 files changed, 352 insertions(+), 306 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 b907d3e5e000..10b5043325cc 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 diff --git a/BaseTools/Scripts/FormatDosFiles.py b/BaseTools/Scripts/Format= DosFiles.py index 2f2d4d532c76..3b16af5a4413 100644 --- a/BaseTools/Scripts/FormatDosFiles.py +++ b/BaseTools/Scripts/FormatDosFiles.py @@ -16,6 +16,7 @@ # # Import Modules # +from __future__ import print_function import argparse import os import os.path diff --git a/BaseTools/Scripts/MemoryProfileSymbolGen.py b/BaseTools/Script= s/MemoryProfileSymbolGen.py index 5709ad4641cb..0a41f9d83271 100644 --- a/BaseTools/Scripts/MemoryProfileSymbolGen.py +++ b/BaseTools/Scripts/MemoryProfileSymbolGen.py @@ -14,6 +14,7 @@ # ## =20 +from __future__ import print_function import os import re import sys @@ -58,10 +59,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 +112,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 +255,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/PackageDocumentTools/packagedoc_cli.py b/Bas= eTools/Scripts/PackageDocumentTools/packagedoc_cli.py index 557ffa4505e4..4deeee01a5e8 100644 --- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py +++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from __future__ import print_function import os, sys, logging, traceback, subprocess from optparse import OptionParser =20 @@ -62,7 +63,7 @@ def parseCmdArgs(): default =3D "C:\\Program Files\\doxygen\\bin\\doxygen.exe" if options.DoxygenPath is None: if os.path.exists(default): - print "Warning: Assume doxygen tool is installed at %s. If not= , please specify via -x" % default + print("Warning: Assume doxygen tool is installed at %s. If not= , please specify via -x" % default) options.DoxygenPath =3D default else: errors.append('- Please specify the path of doxygen tool insta= llation via option -x! or install it in default path %s' % default) @@ -80,7 +81,7 @@ def parseCmdArgs(): if options.PackagePath is not None and os.path.exists(options.Pack= agePath): dirpath =3D os.path.dirname(options.PackagePath) default =3D os.path.join (dirpath, "Document") - print 'Warning: Assume document output at %s. If not, please s= pecify via option -o' % default + print('Warning: Assume document output at %s. If not, please s= pecify via option -o' % default) options.OutputPath =3D default if not os.path.exists(default): try: @@ -92,21 +93,21 @@ def parseCmdArgs(): =20 if options.Arch is None: options.Arch =3D 'ALL' - print "Warning: Assume arch is \"ALL\". If not, specify via -a" + print("Warning: Assume arch is \"ALL\". If not, specify via -a") =20 if options.DocumentMode is None: options.DocumentMode =3D "HTML" - print "Warning: Assume document mode is \"HTML\". If not, specify = via -m" + print("Warning: Assume document mode is \"HTML\". If not, specify = via -m") =20 if options.IncludeOnly is None: options.IncludeOnly =3D False - print "Warning: Assume generate package document for all package\'= s source including publich interfaces and implementation libraries and modu= les." + print("Warning: Assume generate package document for all package\'= s source including publich interfaces and implementation libraries and modu= les.") =20 if options.DocumentMode.lower() =3D=3D 'chm': default =3D "C:\\Program Files\\HTML Help Workshop\\hhc.exe" if options.HtmlWorkshopPath is None: if os.path.exists(default): - print 'Warning: Assume the installation path of Microsoft = HTML Workshop is %s. If not, specify via option -c.' % default + print('Warning: Assume the installation path of Microsoft = HTML Workshop is %s. If not, specify via option -c.' % default) options.HtmlWorkshopPath =3D default else: errors.append('- Please specify the installation path of M= icrosoft HTML Workshop via option -c!') @@ -114,7 +115,7 @@ def parseCmdArgs(): errors.append('- The installation path of Microsoft HTML Works= hop %s does not exists. ' % options.HtmlWorkshopPath) =20 if len(errors) !=3D 0: - print '\n' + print('\n') parser.error('Fail to start due to following reasons: \n%s' %'\n'.= join(errors)) return (options.WorkspacePath, options.PackagePath, options.DoxygenPat= h, options.OutputPath, options.Arch, options.DocumentMode, options.IncludeOnly, optio= ns.HtmlWorkshopPath) @@ -130,21 +131,21 @@ def createPackageObject(wsPath, pkgPath): return pkgObj =20 def callbackLogMessage(msg, level): - print msg.strip() + print(msg.strip()) =20 def callbackCreateDoxygenProcess(doxPath, configPath): if sys.platform =3D=3D 'win32': cmd =3D '"%s" %s' % (doxPath, configPath) else: cmd =3D '%s %s' % (doxPath, configPath) - print cmd + print(cmd) subprocess.call(cmd, shell=3DTrue) =20 =20 def DocumentFixup(outPath, arch): # find BASE_LIBRARY_JUMP_BUFFER structure reference page =20 - print '\n >>> Start fixup document \n' + print('\n >>> Start fixup document \n') =20 for root, dirs, files in os.walk(outPath): for dir in dirs: @@ -172,10 +173,10 @@ def DocumentFixup(outPath, arch): if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint= .h File Reference') !=3D -1: FixPageUefiApplicationEntryPoint(fullpath, text) =20 - print ' >>> Finish all document fixing up! \n' + print(' >>> Finish all document fixing up! \n') =20 def FixPageBaseLib(path, text): - print ' >>> Fixup BaseLib file page at file %s \n' % path + print(' >>> Fixup BaseLib file page at file %s \n' % path) lines =3D text.split('\n') lastBaseJumpIndex =3D -1 lastIdtGateDescriptor =3D -1 @@ -211,10 +212,10 @@ def FixPageBaseLib(path, text): except: logging.getLogger().error(" <<< Fail to fixup file %s\n" % pat= h) return - print " <<< Finish to fixup file %s\n" % path + print(" <<< Finish to fixup file %s\n" % path) =20 def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text): - print ' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at f= ile %s \n' % path + print(' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at f= ile %s \n' % path) lines =3D text.split('\n') for index in range(len(lines) - 1, -1, -1): line =3D lines[index].strip() @@ -229,10 +230,10 @@ def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text): except: logging.getLogger().error(" <<< Fail to fixup file %s\n" % pat= h) return - print " <<< Finish to fixup file %s\n" % path + print(" <<< Finish to fixup file %s\n" % path) =20 def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text): - print ' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at f= ile %s \n' % path + print(' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at f= ile %s \n' % path) lines =3D text.split('\n') bInDetail =3D True bNeedRemove =3D False @@ -266,10 +267,10 @@ def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text): except: logging.getLogger().error(" <<< Fail to fixup file %s" % path) return - print " <<< Finish to fixup file %s\n" % path + print(" <<< Finish to fixup file %s\n" % path) =20 def FixPageUefiDriverEntryPoint(path, text): - print ' >>> Fixup file reference MdePkg/Include/Library/UefiDriverE= ntryPoint.h at file %s \n' % path + print(' >>> Fixup file reference MdePkg/Include/Library/UefiDriverE= ntryPoint.h at file %s \n' % path) lines =3D text.split('\n') bInModuleEntry =3D False bInEfiMain =3D False @@ -318,11 +319,11 @@ def FixPageUefiDriverEntryPoint(path, text): except: logging.getLogger().error(" <<< Fail to fixup file %s" % path) return - print " <<< Finish to fixup file %s\n" % path + print(" <<< Finish to fixup file %s\n" % path) =20 =20 def FixPageUefiApplicationEntryPoint(path, text): - print ' >>> Fixup file reference MdePkg/Include/Library/UefiApplica= tionEntryPoint.h at file %s \n' % path + print(' >>> Fixup file reference MdePkg/Include/Library/UefiApplica= tionEntryPoint.h at file %s \n' % path) lines =3D text.split('\n') bInModuleEntry =3D False bInEfiMain =3D False @@ -371,7 +372,7 @@ def FixPageUefiApplicationEntryPoint(path, text): except: logging.getLogger().error(" <<< Fail to fixup file %s" % path) return - print " <<< Finish to fixup file %s\n" % path + print(" <<< Finish to fixup file %s\n" % path) =20 if __name__ =3D=3D '__main__': wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath =3D= parseCmdArgs() @@ -424,6 +425,6 @@ if __name__ =3D=3D '__main__': else: cmd =3D '%s %s' % (hwpath, indexpath) subprocess.call(cmd) - print '\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.chm') + print('\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.chm')) else: - print '\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.html') + print('\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.html')) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/doxygen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugin= s/basemodel/doxygen.py index a177590af597..fe2ba1d8a842 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/d= oxygen.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/d= oxygen.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from __future__ import print_function import os =20 from message import * @@ -446,4 +447,4 @@ if __name__=3D=3D '__main__': p.AddPage(Page('PCD', 'pcds')) =20 df.Generate() - print df + print(df) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlug= ins/basemodel/efibinary.py index 9db16a63c07a..290287b817e7 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/e= fibinary.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/e= fibinary.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from __future__ import print_function import array import uuid import re @@ -250,12 +251,12 @@ class EfiFirmwareVolumeHeader(BinaryItem): return list2int(self._arr.tolist()[48:50]) =20 def Dump(self): - print 'Signature: %s' % self.GetSigunature() - print 'Attribute: 0x%X' % self.GetAttribute() - print 'Header Length: 0x%X' % self.GetHeaderLength() - print 'File system Guid: ', self.GetFileSystemGuid() - print 'Revision: 0x%X' % self.GetRevision() - print 'FvLength: 0x%X' % self.GetFvLength() + print('Signature: %s' % self.GetSigunature()) + print('Attribute: 0x%X' % self.GetAttribute()) + print('Header Length: 0x%X' % self.GetHeaderLength()) + print('File system Guid: ', self.GetFileSystemGuid()) + print('Revision: 0x%X' % self.GetRevision()) + print('FvLength: 0x%X' % self.GetFvLength()) =20 def GetFileSystemGuid(self): list =3D self._arr.tolist() @@ -348,7 +349,7 @@ class EfiFfs(object): line.append('0x%X' % int(item)) count +=3D 1 else: - print ' '.join(line) + print(' '.join(line)) count =3D 0 line =3D [] line.append('0x%X' % int(item)) @@ -445,11 +446,11 @@ class EfiFfsHeader(BinaryItem): return 'Unknown Ffs State' =20 def Dump(self): - print "FFS name: ", self.GetNameGuid() - print "FFS type: ", self.GetType() - print "FFS attr: 0x%X" % self.GetAttributes() - print "FFS size: 0x%X" % self.GetFfsSize() - print "FFS state: 0x%X" % self.GetState() + print("FFS name: ", self.GetNameGuid()) + print("FFS type: ", self.GetType()) + print("FFS attr: 0x%X" % self.GetAttributes()) + print("FFS size: 0x%X" % self.GetFfsSize()) + print("FFS state: 0x%X" % self.GetState()) =20 def GetRawData(self): return self._arr.tolist() @@ -528,8 +529,8 @@ class EfiSectionHeader(BinaryItem): return self.section_type_map[type] =20 def Dump(self): - print 'size =3D 0x%X' % self.GetSectionSize() - print 'type =3D 0x%X' % self.GetType() + print('size =3D 0x%X' % self.GetSectionSize()) + print('type =3D 0x%X' % self.GetType()) =20 =20 =20 diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py b/BaseTools/Sc= ripts/SmiHandlerProfileSymbolGen.py index 26c092410386..8ad5d471d052 100644 --- a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py +++ b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py @@ -14,6 +14,7 @@ # ## =20 +from __future__ import print_function import os import re import sys @@ -61,10 +62,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 +104,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 +236,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 +278,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 +290,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 +303,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 72d801df8fd5..e268c4c0a1cf 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -15,6 +15,7 @@ =20 ## Import Modules # +from __future__ import print_function import Common.LongFilePathOs as os import re import os.path as path @@ -688,7 +689,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): @@ -4362,7 +4363,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 ad1919442e6e..d4daa3093761 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 @@ -597,19 +598,19 @@ if __name__ =3D=3D '__main__': EdkLogger.Initialize() if len(sys.argv) > 1: Br =3D BuildRule(sys.argv[1]) - print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1]) - print - print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1]) - print - print str(Br[".c", SUP_MODULE_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", SUP_MODULE_SEC, "IPF", "COMMON"][1]) - print - print str(Br[".s", SUP_MODULE_SEC][1]) + print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])) + print() + print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])) + print() + print(str(Br[".c", SUP_MODULE_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", SUP_MODULE_SEC, "IPF", "COMMON"][1])) + print() + print(str(Br[".s", SUP_MODULE_SEC][1])) =20 diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/= Source/Python/AutoGen/UniClassObject.py index 06cf3e7d5162..3a931c6f2766 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/BPDG/BPDG.py b/BaseTools/Source/Python= /BPDG/BPDG.py index 6c8f89f5d12b..86c44abb67a6 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/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 7b04dcdb36cc..c63030a16e6e 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 @@ -1028,10 +1029,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/RangeExpression.py b/BaseTools/= Source/Python/Common/RangeExpression.py index b6f99447057c..4c29bc9ee4bd 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 @@ -85,11 +86,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 f8459c892e36..8ba8dd31a8c5 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 @@ -158,6 +159,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 8ff544ed769d..09b8196faf07 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 @@ -248,7 +249,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): except Exception as X: EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData= =3Dstr(X)) (out, error) =3D PopenObject.communicate() - print out + print(out) while PopenObject.returncode is None : PopenObject.wait() =20 diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Pyth= on/Ecc/CParser.py index ddc6cbd506aa..80cf278cf87c 100644 --- a/BaseTools/Source/Python/Ecc/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser.py @@ -1,5 +1,6 @@ # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53 =20 +from __future__ import print_function from antlr3 import * from antlr3.compat import set, frozenset =20 @@ -102,7 +103,7 @@ class CParser(Parser): self.postfix_expression_stack =3D [] =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 ffa51de7c1bf..2efae2c7c1de 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 @@ -533,58 +534,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 217b60f4f319..4711bbd54fdc 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 * @@ -419,9 +420,9 @@ class Configuration(object): self.__dict__[_ConfigFileToInternalTranslation[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]) =20 # # test that our dict and out class still match in contents. 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 fc65e9a2bd3c..a056c3759fb1 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 d5fb80fcf982..811106133cb4 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 99b22725e6ba..e2a5cc8487fa 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 @@ -2285,7 +2286,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: @@ -2438,7 +2439,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 @@ -2469,7 +2470,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 @@ -2634,9 +2635,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 ddc6cbd506aa..80cf278cf87c 100644 --- a/BaseTools/Source/Python/Eot/CParser.py +++ b/BaseTools/Source/Python/Eot/CParser.py @@ -1,5 +1,6 @@ # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53 =20 +from __future__ import print_function from antlr3 import * from antlr3.compat import set, frozenset =20 @@ -102,7 +103,7 @@ class CParser(Parser): self.postfix_expression_stack =3D [] =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 87f179206d84..1e30e2ce62e2 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 @@ -379,49 +380,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 ## # @@ -430,4 +431,4 @@ class CodeFragmentCollector: # if __name__ =3D=3D "__main__": =20 - print "For Test." + print("For Test.") diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Sourc= e/Python/Eot/InfParserLite.py index 584a95d6f3e4..24f0d50246e5 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 20f3e3999b90..a61837e27b31 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 @@ -4765,7 +4766,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) @@ -4773,7 +4774,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 ba3950dacd8a..1552ab4ee3a8 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 @@ -689,7 +690,7 @@ class GenFds : ModuleDict =3D BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlob= alVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules for Key in ModuleDict: ModuleObj =3D BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGloba= lVariable.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 c1d656227609..73b52030d929 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 @@ -736,7 +737,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 f40c8bd01b23..d7084fbe88da 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 @@ -216,7 +217,7 @@ if __name__ =3D=3D '__main__': (options, args) =3D parser.parse_args() =20 if options.mapfile is None or options.efifile is 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 is not None: @@ -225,6 +226,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 9711de8f5c2e..41bcaa0437c5 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 d36a14ffb775..2944b634fb7a 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 dgst -sha256 -prverify "%s" -signatur= e %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), std= in=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, s= hell=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 9fb89549cc29..0d4a59198e7b 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, @@ -83,14 +84,14 @@ class TargetTool(): errMsg =3D '' for Key in self.TargetTxtDictionary: 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] is 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: @@ -109,7 +110,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 @@ -120,7 +121,7 @@ class TargetTool(): fw.write(Line) for key in self.TargetTxtDictionary: if key not in existKeys: - print "Warning: %s does not exist in original configur= ation file" % key + print("Warning: %s does not exist in original configur= ation file" % key) Line =3D GetConfigureKeyValue(self, key) if Line is None: Line =3D "%-30s =3D " % key @@ -223,25 +224,25 @@ if __name__ =3D=3D '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.QUIET) if os.getenv('WORKSPACE') is 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 is not None and opt.NUM < 1: - print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0." + print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.") sys.exit(1) if opt.TARGET is not None and len(opt.TARGET) > 1: for elem in opt.TARGET: if elem =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 is not 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 299cd871444b..a464cbf702f7 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 @@ -730,7 +731,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_'): @@ -1022,12 +1023,12 @@ class UniFileClassObject(object): # Show the instance itself # def ShowMe(self): - print self.LanguageDef + print(self.LanguageDef) #print self.OrderedStringList for Item in self.OrderedStringList: - print Item + print(Item) for Member in self.OrderedStringList[Item]: - print str(Member) + print(str(Member)) =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 a001162e8e3b..7f289c103fb9 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.StringUtils import * from Common.DataType import * from Common.Misc import * @@ -1373,7 +1374,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]]: @@ -1808,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) except: - print "error" + print("error") try: Value, ValueSize =3D ParseFieldValue (FieldList[FieldN= ame][0]) except Exception: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index a8f13d52c42d..2815c83af1b3 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 @@ -1639,7 +1640,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 4600c46be1be..416aa73549d1 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 @@ -2195,7 +2196,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..be7b4ad42856 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -1,3 +1,4 @@ +from __future__ import print_function ## @file # Utility functions and classes for BaseTools unit tests # @@ -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.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel