From 9d7e1e56a727743a811abfed92e1ede39ecbfa8c Mon Sep 17 00:00:00 2001 From: Yunhua Feng Date: Tue, 28 Aug 2018 17:00:24 +0800 Subject: BaseTools/Scripts: Porting PackageDocumentTools code to use Python3 Porting PackageDocumentTools code to Python3 DoxyGen 1.8.6 wxpython 4.0.3 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Liming Gao --- BaseTools/Scripts/PackageDocumentTools/Readme.md | 4 +- .../Scripts/PackageDocumentTools/packagedoc_cli.py | 7 ++- .../Scripts/PackageDocumentTools/packagedocapp.pyw | 54 +++++++++++----------- .../plugins/EdkPlugins/basemodel/doxygen.py | 8 ++-- .../plugins/EdkPlugins/basemodel/efibinary.py | 1 - .../plugins/EdkPlugins/basemodel/ini.py | 5 +- .../plugins/EdkPlugins/edk2/model/baseobject.py | 14 +++--- .../plugins/EdkPlugins/edk2/model/dec.py | 4 +- .../plugins/EdkPlugins/edk2/model/doxygengen.py | 12 ++--- .../EdkPlugins/edk2/model/doxygengen_spec.py | 12 ++--- .../plugins/EdkPlugins/edk2/model/dsc.py | 4 +- .../plugins/EdkPlugins/edk2/model/inf.py | 4 +- 12 files changed, 62 insertions(+), 67 deletions(-) diff --git a/BaseTools/Scripts/PackageDocumentTools/Readme.md b/BaseTools/Scripts/PackageDocumentTools/Readme.md index dfc2892..f8f81e3 100644 --- a/BaseTools/Scripts/PackageDocumentTools/Readme.md +++ b/BaseTools/Scripts/PackageDocumentTools/Readme.md @@ -1,6 +1,6 @@ Prerequisite Tools: -1. Install Python 2.7.3 from https://www.python.org/download/releases/2.7.3/ -2. Install wxPython 2.8.12.1 from https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/ +1. Install Python 3.6.6 from https://www.python.org/downloads/release/python-366/ +2. Install wxPython 4.0.3 from https://pypi.org/project/wxPython/#files generally the libraries will be installed at python's subfolder, for example in windows: c:\python27\Lib\site-packages\ 3. Install DoxyGen 1.8.6 from https://sourceforge.net/projects/doxygen/files/rel-1.8.6/ 4. (Windows only) Install Htmlhelp tool from https://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py index 4deeee0..94c0049 100644 --- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py +++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py @@ -12,12 +12,11 @@ # 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 -import plugins.EdkPlugins.edk2.model.baseobject as baseobject -import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen +from .plugins.EdkPlugins.edk2.model import baseobject +from .plugins.EdkPlugins.edk2.model import doxygengen gArchMarcoDict = {'ALL' : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER', 'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS', @@ -38,7 +37,7 @@ def parseCmdArgs(): help='Specify the absolute path of doxygen tools installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe') parser.add_option('-o', '--output', action='store', dest='OutputPath', help='Specify the document output path. For example: c:\\docoutput') - parser.add_option('-a', '--arch', action='store', dest='Arch', choices=gArchMarcoDict.keys(), + parser.add_option('-a', '--arch', action='store', dest='Arch', choices=list(gArchMarcoDict.keys()), help='Specify the architecture used in preprocess package\'s source. For example: -a IA32_MSFT') parser.add_option('-m', '--mode', action='store', dest='DocumentMode', choices=['CHM', 'HTML'], help='Specify the document mode from : CHM or HTML') diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw b/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw index 28f6f9b..f81ecfd 100644 --- a/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw +++ b/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw @@ -18,8 +18,8 @@ import os, sys, wx, logging import wx.stc import wx.lib.newevent import wx.lib.agw.genericmessagedialog as GMD -import plugins.EdkPlugins.edk2.model.baseobject as baseobject -import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen +from plugins.EdkPlugins.edk2.model import baseobject +from plugins.EdkPlugins.edk2.model import doxygengen if hasattr(sys, "frozen"): appPath = os.path.abspath(os.path.dirname(sys.executable)) @@ -42,7 +42,7 @@ class PackageDocApp(wx.App): frame.Show(True) - EVT_APP_CALLBACK( self, self.OnAppCallBack) + self.Bind(EVT_APP_CALLBACK, self.OnAppCallBack) return True def GetLogger(self): @@ -60,13 +60,13 @@ class PackageDocApp(wx.App): class PackageDocMainFrame(wx.Frame): def __init__(self, parent, title): - wx.Frame.__init__(self, parent, -1, title, size=(550, 290), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX ) + wx.Frame.__init__(self, parent, -1, title, size=(550, 350), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX ) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) subsizer = wx.GridBagSizer(5, 10) - subsizer.AddGrowableCol(1) + subsizer.AddGrowableCol(0) subsizer.Add(wx.StaticText(panel, -1, "Workspace Location : "), (0, 0), flag=wx.ALIGN_CENTER_VERTICAL) self._workspacePathCtrl = wx.ComboBox(panel, -1) list = self.GetConfigure("WorkspacePath") @@ -76,9 +76,9 @@ class PackageDocMainFrame(wx.Frame): self._workspacePathCtrl.SetValue(list[len(list) - 1]) subsizer.Add(self._workspacePathCtrl, (0, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) - self._workspacePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + self._workspacePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) subsizer.Add(self._workspacePathBt, (0, 2), flag=wx.ALIGN_CENTER_VERTICAL) - wx.EVT_BUTTON(self._workspacePathBt, self._workspacePathBt.GetId(), self.OnBrowsePath) + self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._workspacePathBt) subsizer.Add(wx.StaticText(panel, -1, "Package DEC Location : "), (1, 0), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) self._packagePathCtrl = wx.ComboBox(panel, -1) @@ -88,9 +88,9 @@ class PackageDocMainFrame(wx.Frame): self._packagePathCtrl.Append(item) self._packagePathCtrl.SetValue(list[len(list) - 1]) subsizer.Add(self._packagePathCtrl, (1, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) - self._packagePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + self._packagePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) subsizer.Add(self._packagePathBt, (1, 2), flag=wx.ALIGN_CENTER_VERTICAL) - wx.EVT_BUTTON(self._packagePathBt, self._packagePathBt.GetId(), self.OnBrowsePath) + self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._packagePathBt) subsizer.Add(wx.StaticText(panel, -1, "Doxygen Tool Location : "), (2, 0), flag=wx.ALIGN_CENTER_VERTICAL) self._doxygenPathCtrl = wx.TextCtrl(panel, -1) @@ -103,10 +103,10 @@ class PackageDocMainFrame(wx.Frame): else: self._doxygenPathCtrl.SetValue('/usr/bin/doxygen') - self._doxygenPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + self._doxygenPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) subsizer.Add(self._doxygenPathCtrl, (2, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) subsizer.Add(self._doxygenPathBt, (2, 2), flag=wx.ALIGN_CENTER_VERTICAL) - wx.EVT_BUTTON(self._doxygenPathBt, self._doxygenPathBt.GetId(), self.OnBrowsePath) + self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._doxygenPathBt) subsizer.Add(wx.StaticText(panel, -1, "CHM Tool Location : "), (3, 0), flag=wx.ALIGN_CENTER_VERTICAL) self._chmPathCtrl = wx.TextCtrl(panel, -1) @@ -116,10 +116,10 @@ class PackageDocMainFrame(wx.Frame): else: self._chmPathCtrl.SetValue('C:\\Program Files\\HTML Help Workshop\\hhc.exe') - self._chmPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + self._chmPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) subsizer.Add(self._chmPathCtrl, (3, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) subsizer.Add(self._chmPathBt, (3, 2), flag=wx.ALIGN_CENTER_VERTICAL) - wx.EVT_BUTTON(self._chmPathBt, self._chmPathBt.GetId(), self.OnBrowsePath) + self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._chmPathBt) subsizer.Add(wx.StaticText(panel, -1, "Output Location : "), (4, 0), flag=wx.ALIGN_CENTER_VERTICAL) self._outputPathCtrl = wx.ComboBox(panel, -1) @@ -130,9 +130,9 @@ class PackageDocMainFrame(wx.Frame): self._outputPathCtrl.SetValue(list[len(list) - 1]) subsizer.Add(self._outputPathCtrl, (4, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) - self._outputPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + self._outputPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) subsizer.Add(self._outputPathBt, (4, 2), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) - wx.EVT_BUTTON(self._outputPathBt, self._outputPathBt.GetId(), self.OnBrowsePath) + self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._outputPathBt) subsizer.Add(wx.StaticText(panel, -1, "Architecture Specified : "), (5, 0), flag=wx.ALIGN_CENTER_VERTICAL) self._archCtrl = wx.ComboBox(panel, -1, value='ALL', choices=['ALL', 'IA32/MSFT', 'IA32/GNU', 'X64/INTEL', 'X64/GNU', 'IPF/MSFT', 'IPF/GNU', 'EBC/INTEL'], @@ -164,7 +164,7 @@ class PackageDocMainFrame(wx.Frame): def SaveConfigure(self, name, value): if value ==None or len(value) == 0: return - config = wx.ConfigBase_Get() + config = wx.ConfigBase.Get() oldvalues = config.Read(name, '').split(';') if len(oldvalues) >= 10: oldvalues.remove(oldvalues[0]) @@ -177,7 +177,7 @@ class PackageDocMainFrame(wx.Frame): config.Write(name, ';'.join(oldvalues)) def GetConfigure(self, name): - config = wx.ConfigBase_Get() + config = wx.ConfigBase.Get() values = config.Read(name, '').split(';') list = [] for item in values: @@ -416,10 +416,10 @@ class ProgressDialog(wx.Dialog): logging.getLogger('').addHandler(self._loghandle) logging.getLogger('app').addHandler(self._loghandle) - wx.EVT_BUTTON(self._closeBt, self._closeBt.GetId(), self.OnButtonClose) - wx.EVT_UPDATE_UI(self, self._closeBt.GetId(), self.OnUpdateCloseButton) - wx.EVT_BUTTON(self._gotoOuputBt, self._gotoOuputBt.GetId(), self.OnGotoOutput) - EVT_LOG(self, self.OnPostLog) + self.Bind(wx.EVT_BUTTON, self.OnButtonClose, self._closeBt) + self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCloseButton) + self.Bind(wx.EVT_BUTTON, self.OnGotoOutput, self._gotoOuputBt) + self.Bind(EVT_LOG, self.OnPostLog) self._process = None self._pid = None @@ -720,7 +720,7 @@ class ProgressDialog(wx.Dialog): lines = f.readlines() f.close() bfound = False - for index in xrange(len(lines)): + for index in range(len(lines)): if lines[index].find('File List') != -1: lines[index] = "