BaseTools: Refactor python print statements
Refactor print statements to be compatible with python 3. Based on "futurize -f libfuturize.fixes.fix_print_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
'''
|
||||
BinToPcd
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import os
|
||||
import os.path
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#
|
||||
##
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -58,10 +59,10 @@ class Symbols:
|
||||
try:
|
||||
nmCommand = "nm"
|
||||
nmLineOption = "-l"
|
||||
print "parsing (debug) - " + pdbName
|
||||
print("parsing (debug) - " + pdbName)
|
||||
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))
|
||||
except :
|
||||
print 'ERROR: nm command not available. Please verify PATH'
|
||||
print('ERROR: nm command not available. Please verify PATH')
|
||||
return
|
||||
|
||||
#
|
||||
@@ -111,11 +112,11 @@ class Symbols:
|
||||
DIA2DumpCommand = "Dia2Dump.exe"
|
||||
#DIA2SymbolOption = "-p"
|
||||
DIA2LinesOption = "-l"
|
||||
print "parsing (pdb) - " + pdbName
|
||||
print("parsing (pdb) - " + pdbName)
|
||||
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))
|
||||
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))
|
||||
except :
|
||||
print 'ERROR: DIA2Dump command not available. Please verify PATH'
|
||||
print('ERROR: DIA2Dump command not available. Please verify PATH')
|
||||
return
|
||||
|
||||
#
|
||||
@@ -254,12 +255,12 @@ def main():
|
||||
try :
|
||||
file = open(Options.inputfilename)
|
||||
except Exception:
|
||||
print "fail to open " + Options.inputfilename
|
||||
print("fail to open " + Options.inputfilename)
|
||||
return 1
|
||||
try :
|
||||
newfile = open(Options.outputfilename, "w")
|
||||
except Exception:
|
||||
print "fail to open " + Options.outputfilename
|
||||
print("fail to open " + Options.outputfilename)
|
||||
return 1
|
||||
|
||||
try:
|
||||
|
@@ -12,6 +12,7 @@
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import os, sys, logging, traceback, subprocess
|
||||
from optparse import OptionParser
|
||||
|
||||
@@ -62,7 +63,7 @@ def parseCmdArgs():
|
||||
default = "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 = default
|
||||
else:
|
||||
errors.append('- Please specify the path of doxygen tool installation 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.PackagePath):
|
||||
dirpath = os.path.dirname(options.PackagePath)
|
||||
default = os.path.join (dirpath, "Document")
|
||||
print 'Warning: Assume document output at %s. If not, please specify via option -o' % default
|
||||
print('Warning: Assume document output at %s. If not, please specify via option -o' % default)
|
||||
options.OutputPath = default
|
||||
if not os.path.exists(default):
|
||||
try:
|
||||
@@ -92,21 +93,21 @@ def parseCmdArgs():
|
||||
|
||||
if options.Arch is None:
|
||||
options.Arch = 'ALL'
|
||||
print "Warning: Assume arch is \"ALL\". If not, specify via -a"
|
||||
print("Warning: Assume arch is \"ALL\". If not, specify via -a")
|
||||
|
||||
if options.DocumentMode is None:
|
||||
options.DocumentMode = "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")
|
||||
|
||||
if options.IncludeOnly is None:
|
||||
options.IncludeOnly = False
|
||||
print "Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules."
|
||||
print("Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules.")
|
||||
|
||||
if options.DocumentMode.lower() == 'chm':
|
||||
default = "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 = default
|
||||
else:
|
||||
errors.append('- Please specify the installation path of Microsoft HTML Workshop via option -c!')
|
||||
@@ -114,7 +115,7 @@ def parseCmdArgs():
|
||||
errors.append('- The installation path of Microsoft HTML Workshop %s does not exists. ' % options.HtmlWorkshopPath)
|
||||
|
||||
if len(errors) != 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.DoxygenPath, options.OutputPath,
|
||||
options.Arch, options.DocumentMode, options.IncludeOnly, options.HtmlWorkshopPath)
|
||||
@@ -130,21 +131,21 @@ def createPackageObject(wsPath, pkgPath):
|
||||
return pkgObj
|
||||
|
||||
def callbackLogMessage(msg, level):
|
||||
print msg.strip()
|
||||
print(msg.strip())
|
||||
|
||||
def callbackCreateDoxygenProcess(doxPath, configPath):
|
||||
if sys.platform == 'win32':
|
||||
cmd = '"%s" %s' % (doxPath, configPath)
|
||||
else:
|
||||
cmd = '%s %s' % (doxPath, configPath)
|
||||
print cmd
|
||||
print(cmd)
|
||||
subprocess.call(cmd, shell=True)
|
||||
|
||||
|
||||
def DocumentFixup(outPath, arch):
|
||||
# find BASE_LIBRARY_JUMP_BUFFER structure reference page
|
||||
|
||||
print '\n >>> Start fixup document \n'
|
||||
print('\n >>> Start fixup document \n')
|
||||
|
||||
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') != -1:
|
||||
FixPageUefiApplicationEntryPoint(fullpath, text)
|
||||
|
||||
print ' >>> Finish all document fixing up! \n'
|
||||
print(' >>> Finish all document fixing up! \n')
|
||||
|
||||
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 = text.split('\n')
|
||||
lastBaseJumpIndex = -1
|
||||
lastIdtGateDescriptor = -1
|
||||
@@ -211,10 +212,10 @@ def FixPageBaseLib(path, text):
|
||||
except:
|
||||
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)
|
||||
return
|
||||
print " <<< Finish to fixup file %s\n" % path
|
||||
print(" <<< Finish to fixup file %s\n" % path)
|
||||
|
||||
def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
|
||||
print ' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path
|
||||
print(' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path)
|
||||
lines = text.split('\n')
|
||||
for index in range(len(lines) - 1, -1, -1):
|
||||
line = lines[index].strip()
|
||||
@@ -229,10 +230,10 @@ def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
|
||||
except:
|
||||
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)
|
||||
return
|
||||
print " <<< Finish to fixup file %s\n" % path
|
||||
print(" <<< Finish to fixup file %s\n" % path)
|
||||
|
||||
def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):
|
||||
print ' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path
|
||||
print(' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path)
|
||||
lines = text.split('\n')
|
||||
bInDetail = True
|
||||
bNeedRemove = 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)
|
||||
|
||||
def FixPageUefiDriverEntryPoint(path, text):
|
||||
print ' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path
|
||||
print(' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path)
|
||||
lines = text.split('\n')
|
||||
bInModuleEntry = False
|
||||
bInEfiMain = 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)
|
||||
|
||||
|
||||
def FixPageUefiApplicationEntryPoint(path, text):
|
||||
print ' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path
|
||||
print(' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path)
|
||||
lines = text.split('\n')
|
||||
bInModuleEntry = False
|
||||
bInEfiMain = 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)
|
||||
|
||||
if __name__ == '__main__':
|
||||
wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = parseCmdArgs()
|
||||
@@ -424,6 +425,6 @@ if __name__ == '__main__':
|
||||
else:
|
||||
cmd = '%s %s' % (hwpath, indexpath)
|
||||
subprocess.call(cmd)
|
||||
print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm')
|
||||
print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm'))
|
||||
else:
|
||||
print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html')
|
||||
print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html'))
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
|
||||
from message import *
|
||||
@@ -446,4 +447,4 @@ if __name__== '__main__':
|
||||
p.AddPage(Page('PCD', 'pcds'))
|
||||
|
||||
df.Generate()
|
||||
print df
|
||||
print(df)
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
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])
|
||||
|
||||
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())
|
||||
|
||||
def GetFileSystemGuid(self):
|
||||
list = self._arr.tolist()
|
||||
@@ -348,7 +349,7 @@ class EfiFfs(object):
|
||||
line.append('0x%X' % int(item))
|
||||
count += 1
|
||||
else:
|
||||
print ' '.join(line)
|
||||
print(' '.join(line))
|
||||
count = 0
|
||||
line = []
|
||||
line.append('0x%X' % int(item))
|
||||
@@ -445,11 +446,11 @@ class EfiFfsHeader(BinaryItem):
|
||||
return 'Unknown Ffs State'
|
||||
|
||||
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())
|
||||
|
||||
def GetRawData(self):
|
||||
return self._arr.tolist()
|
||||
@@ -528,8 +529,8 @@ class EfiSectionHeader(BinaryItem):
|
||||
return self.section_type_map[type]
|
||||
|
||||
def Dump(self):
|
||||
print 'size = 0x%X' % self.GetSectionSize()
|
||||
print 'type = 0x%X' % self.GetType()
|
||||
print('size = 0x%X' % self.GetSectionSize())
|
||||
print('type = 0x%X' % self.GetType())
|
||||
|
||||
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#
|
||||
##
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -61,10 +62,10 @@ class Symbols:
|
||||
try:
|
||||
nmCommand = "nm"
|
||||
nmLineOption = "-l"
|
||||
print "parsing (debug) - " + pdbName
|
||||
print("parsing (debug) - " + pdbName)
|
||||
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))
|
||||
except :
|
||||
print 'ERROR: nm command not available. Please verify PATH'
|
||||
print('ERROR: nm command not available. Please verify PATH')
|
||||
return
|
||||
|
||||
#
|
||||
@@ -103,11 +104,11 @@ class Symbols:
|
||||
DIA2DumpCommand = "Dia2Dump.exe"
|
||||
#DIA2SymbolOption = "-p"
|
||||
DIA2LinesOption = "-l"
|
||||
print "parsing (pdb) - " + pdbName
|
||||
print("parsing (pdb) - " + pdbName)
|
||||
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))
|
||||
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))
|
||||
except :
|
||||
print 'ERROR: DIA2Dump command not available. Please verify PATH'
|
||||
print('ERROR: DIA2Dump command not available. Please verify PATH')
|
||||
return
|
||||
|
||||
#
|
||||
@@ -235,14 +236,14 @@ def main():
|
||||
try :
|
||||
DOMTree = xml.dom.minidom.parse(Options.inputfilename)
|
||||
except Exception:
|
||||
print "fail to open input " + Options.inputfilename
|
||||
print("fail to open input " + Options.inputfilename)
|
||||
return 1
|
||||
|
||||
if Options.guidreffilename is not None:
|
||||
try :
|
||||
guidreffile = open(Options.guidreffilename)
|
||||
except Exception:
|
||||
print "fail to open guidref" + Options.guidreffilename
|
||||
print("fail to open guidref" + Options.guidreffilename)
|
||||
return 1
|
||||
genGuidString(guidreffile)
|
||||
guidreffile.close()
|
||||
@@ -277,7 +278,7 @@ def main():
|
||||
|
||||
Handler = smiHandler.getElementsByTagName("Handler")
|
||||
RVA = Handler[0].getElementsByTagName("RVA")
|
||||
print " Handler RVA: %s" % RVA[0].childNodes[0].data
|
||||
print(" Handler RVA: %s" % RVA[0].childNodes[0].data)
|
||||
|
||||
if (len(RVA)) >= 1:
|
||||
rvaName = RVA[0].childNodes[0].data
|
||||
@@ -289,7 +290,7 @@ def main():
|
||||
|
||||
Caller = smiHandler.getElementsByTagName("Caller")
|
||||
RVA = Caller[0].getElementsByTagName("RVA")
|
||||
print " Caller RVA: %s" % RVA[0].childNodes[0].data
|
||||
print(" Caller RVA: %s" % RVA[0].childNodes[0].data)
|
||||
|
||||
if (len(RVA)) >= 1:
|
||||
rvaName = RVA[0].childNodes[0].data
|
||||
@@ -302,7 +303,7 @@ def main():
|
||||
try :
|
||||
newfile = open(Options.outputfilename, "w")
|
||||
except Exception:
|
||||
print "fail to open output" + Options.outputfilename
|
||||
print("fail to open output" + Options.outputfilename)
|
||||
return 1
|
||||
|
||||
newfile.write(DOMTree.toprettyxml(indent = "\t", newl = "\n", encoding = "utf-8"))
|
||||
|
Reference in New Issue
Block a user