summaryrefslogtreecommitdiff
path: root/BaseTools/Scripts
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2018-06-25 18:31:26 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-06-27 16:33:21 +0800
commit72443dd25014a8b6209895640af36dec33da51e0 (patch)
treece91675cb7bfadbd4c8686b19d3d816fb968f612 /BaseTools/Scripts
parent5b0671c1e514e534c6d5be9604da33bfc2cd0a24 (diff)
BaseTools: Refactor python print statements
Refactor print statements to be compatible with python 3. Based on "futurize -f libfuturize.fixes.fix_print_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Scripts')
-rw-r--r--BaseTools/Scripts/BinToPcd.py1
-rw-r--r--BaseTools/Scripts/FormatDosFiles.py1
-rw-r--r--BaseTools/Scripts/MemoryProfileSymbolGen.py13
-rw-r--r--BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py47
-rw-r--r--BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py3
-rw-r--r--BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py29
-rw-r--r--BaseTools/Scripts/SmiHandlerProfileSymbolGen.py19
7 files changed, 60 insertions, 53 deletions
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index b907d3e5e0..10b5043325 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -14,6 +14,7 @@
'''
BinToPcd
'''
+from __future__ import print_function
import sys
import argparse
diff --git a/BaseTools/Scripts/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.py
index 2f2d4d532c..3b16af5a44 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/Scripts/MemoryProfileSymbolGen.py
index 5709ad4641..0a41f9d832 100644
--- a/BaseTools/Scripts/MemoryProfileSymbolGen.py
+++ b/BaseTools/Scripts/MemoryProfileSymbolGen.py
@@ -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:
diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
index 557ffa4505..4deeee01a5 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 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'))
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index a177590af5..fe2ba1d8a8 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -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)
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
index 9db16a63c0..290287b817 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
@@ -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())
diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
index 26c0924103..8ad5d471d0 100644
--- a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
+++ b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
@@ -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"))