mirror of https://github.com/acidanthera/audk.git
BaseTools/Scripts: Porting PackageDocumentTools code to use Python3
Porting PackageDocumentTools code to support python2 and python3 Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
parent
fe90631298
commit
7cc7e054f8
|
@ -135,7 +135,7 @@ class parser_lst(object):
|
||||||
tmp_dict[offset] = tmp_name
|
tmp_dict[offset] = tmp_name
|
||||||
pcdname_num = int(pcdname_num_re.findall(t_name)[0],10)
|
pcdname_num = int(pcdname_num_re.findall(t_name)[0],10)
|
||||||
uint = int(unit_num.findall(uint)[0],10)
|
uint = int(unit_num.findall(uint)[0],10)
|
||||||
bit = uint / 8
|
bit = uint // 8
|
||||||
for i in range(1, pcdname_num):
|
for i in range(1, pcdname_num):
|
||||||
offset += bit
|
offset += bit
|
||||||
tmp_name = pcdname2_re.findall(t_name)[0] + '[%s]' % i
|
tmp_name = pcdname2_re.findall(t_name)[0] + '[%s]' % i
|
||||||
|
|
|
@ -16,8 +16,8 @@ from __future__ import print_function
|
||||||
import os, sys, logging, traceback, subprocess
|
import os, sys, logging, traceback, subprocess
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import plugins.EdkPlugins.edk2.model.baseobject as baseobject
|
from .plugins.EdkPlugins.edk2.model import baseobject
|
||||||
import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
|
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',
|
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',
|
'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
|
||||||
|
@ -38,7 +38,7 @@ def parseCmdArgs():
|
||||||
help='Specify the absolute path of doxygen tools installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe')
|
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',
|
parser.add_option('-o', '--output', action='store', dest='OutputPath',
|
||||||
help='Specify the document output path. For example: c:\\docoutput')
|
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')
|
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'],
|
parser.add_option('-m', '--mode', action='store', dest='DocumentMode', choices=['CHM', 'HTML'],
|
||||||
help='Specify the document mode from : CHM or HTML')
|
help='Specify the document mode from : CHM or HTML')
|
||||||
|
|
|
@ -18,8 +18,8 @@ import os, sys, wx, logging
|
||||||
import wx.stc
|
import wx.stc
|
||||||
import wx.lib.newevent
|
import wx.lib.newevent
|
||||||
import wx.lib.agw.genericmessagedialog as GMD
|
import wx.lib.agw.genericmessagedialog as GMD
|
||||||
import plugins.EdkPlugins.edk2.model.baseobject as baseobject
|
from plugins.EdkPlugins.edk2.model import baseobject
|
||||||
import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
|
from plugins.EdkPlugins.edk2.model import doxygengen
|
||||||
|
|
||||||
if hasattr(sys, "frozen"):
|
if hasattr(sys, "frozen"):
|
||||||
appPath = os.path.abspath(os.path.dirname(sys.executable))
|
appPath = os.path.abspath(os.path.dirname(sys.executable))
|
||||||
|
@ -720,7 +720,7 @@ class ProgressDialog(wx.Dialog):
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
bfound = False
|
bfound = False
|
||||||
for index in xrange(len(lines)):
|
for index in range(len(lines)):
|
||||||
if lines[index].find('<a class="el" href="files.html" target="basefrm">File List</a>') != -1:
|
if lines[index].find('<a class="el" href="files.html" target="basefrm">File List</a>') != -1:
|
||||||
lines[index] = "<!-- %s" % lines[index]
|
lines[index] = "<!-- %s" % lines[index]
|
||||||
bfound = True
|
bfound = True
|
||||||
|
@ -969,7 +969,7 @@ class ProgressDialog(wx.Dialog):
|
||||||
fd = open(path, 'r')
|
fd = open(path, 'r')
|
||||||
text = fd.read()
|
text = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.LogMessage (" <<<Fail to open file %s" % path)
|
self.LogMessage (" <<<Fail to open file %s" % path)
|
||||||
return
|
return
|
||||||
text = text.replace ('.s.dox', '.s')
|
text = text.replace ('.s.dox', '.s')
|
||||||
|
@ -982,7 +982,7 @@ class ProgressDialog(wx.Dialog):
|
||||||
fd = open(path, 'w')
|
fd = open(path, 'w')
|
||||||
fd.write(text)
|
fd.write(text)
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.LogMessage (" <<<Fail to fixup file %s" % path)
|
self.LogMessage (" <<<Fail to fixup file %s" % path)
|
||||||
return
|
return
|
||||||
self.LogMessage(' >>> Finish to fixup .dox postfix for file %s \n' % path)
|
self.LogMessage(' >>> Finish to fixup .dox postfix for file %s \n' % path)
|
||||||
|
@ -993,7 +993,7 @@ class ProgressDialog(wx.Dialog):
|
||||||
fd = open(path, 'r')
|
fd = open(path, 'r')
|
||||||
lines = fd.readlines()
|
lines = fd.readlines()
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.LogMessage (" <<<Fail to open file %s" % path)
|
self.LogMessage (" <<<Fail to open file %s" % path)
|
||||||
return
|
return
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -1004,7 +1004,7 @@ class ProgressDialog(wx.Dialog):
|
||||||
fd = open(path, 'w')
|
fd = open(path, 'w')
|
||||||
fd.write("".join(lines))
|
fd.write("".join(lines))
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.LogMessage (" <<<Fail to fixup file %s" % path)
|
self.LogMessage (" <<<Fail to fixup file %s" % path)
|
||||||
return
|
return
|
||||||
self.LogMessage(' >>> Finish to fixup .decdoxygen postfix for file %s \n' % path)
|
self.LogMessage(' >>> Finish to fixup .decdoxygen postfix for file %s \n' % path)
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Page(BaseDoxygeItem):
|
||||||
|
|
||||||
def AddSection(self, section):
|
def AddSection(self, section):
|
||||||
self.mSections.append(section)
|
self.mSections.append(section)
|
||||||
self.mSections.sort(cmp=lambda x, y: cmp(x.mName.lower(), y.mName.lower()))
|
self.mSections.sort(key=lambda x: x.mName.lower())
|
||||||
|
|
||||||
def Generate(self):
|
def Generate(self):
|
||||||
if self.mIsMainPage:
|
if self.mIsMainPage:
|
||||||
|
@ -80,7 +80,7 @@ class Page(BaseDoxygeItem):
|
||||||
self.mText.append(self.mDescription)
|
self.mText.append(self.mDescription)
|
||||||
endIndex = len(self.mText)
|
endIndex = len(self.mText)
|
||||||
|
|
||||||
self.mSections.sort()
|
self.mSections.sort(key=lambda x: x.mName.lower())
|
||||||
for sect in self.mSections:
|
for sect in self.mSections:
|
||||||
self.mText += sect.Generate()
|
self.mText += sect.Generate()
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
import plugins.EdkPlugins.basemodel.ini as ini
|
from ...basemodel import ini
|
||||||
import plugins.EdkPlugins.edk2.model.dsc as dsc
|
from ...edk2.model import dsc
|
||||||
import plugins.EdkPlugins.edk2.model.inf as inf
|
from ...edk2.model import inf
|
||||||
import plugins.EdkPlugins.edk2.model.dec as dec
|
from ...edk2.model import dec
|
||||||
import os
|
import os
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
class SurfaceObject(object):
|
class SurfaceObject(object):
|
||||||
_objs = {}
|
_objs = {}
|
||||||
|
@ -655,13 +655,13 @@ class Package(SurfaceObject):
|
||||||
return self._pcds
|
return self._pcds
|
||||||
|
|
||||||
def GetPpis(self):
|
def GetPpis(self):
|
||||||
return self._ppis.values()
|
return list(self._ppis.values())
|
||||||
|
|
||||||
def GetProtocols(self):
|
def GetProtocols(self):
|
||||||
return self._protocols.values()
|
return list(self._protocols.values())
|
||||||
|
|
||||||
def GetGuids(self):
|
def GetGuids(self):
|
||||||
return self._guids.values()
|
return list(self._guids.values())
|
||||||
|
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
for pcd in self._pcds.values():
|
for pcd in self._pcds.values():
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
|
|
||||||
import plugins.EdkPlugins.basemodel.ini as ini
|
from ...basemodel import ini
|
||||||
import re, os
|
import re, os
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
class DECFile(ini.BaseINIFile):
|
class DECFile(ini.BaseINIFile):
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"""This file produce action class to generate doxygen document for edk2 codebase.
|
"""This file produce action class to generate doxygen document for edk2 codebase.
|
||||||
The action classes are shared by GUI and command line tools.
|
The action classes are shared by GUI and command line tools.
|
||||||
"""
|
"""
|
||||||
import plugins.EdkPlugins.basemodel.doxygen as doxygen
|
from ...basemodel import doxygen
|
||||||
import os
|
import os
|
||||||
try:
|
try:
|
||||||
import wx
|
import wx
|
||||||
|
@ -24,9 +24,9 @@ try:
|
||||||
except:
|
except:
|
||||||
gInGui = False
|
gInGui = False
|
||||||
import re
|
import re
|
||||||
import plugins.EdkPlugins.edk2.model.inf as inf
|
from ...edk2.model import inf
|
||||||
import plugins.EdkPlugins.edk2.model.dec as dec
|
from ...edk2.model import dec
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
_ignore_dir = ['.svn', '_svn', 'cvs']
|
_ignore_dir = ['.svn', '_svn', 'cvs']
|
||||||
_inf_key_description_mapping_table = {
|
_inf_key_description_mapping_table = {
|
||||||
|
@ -386,7 +386,7 @@ class PackageDocumentAction(DoxygenAction):
|
||||||
configFile.AddFile(path)
|
configFile.AddFile(path)
|
||||||
|
|
||||||
no = 0
|
no = 0
|
||||||
for no in xrange(len(lines)):
|
for no in range(len(lines)):
|
||||||
if len(lines[no].strip()) == 0:
|
if len(lines[no].strip()) == 0:
|
||||||
continue
|
continue
|
||||||
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
|
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
|
||||||
|
@ -1000,7 +1000,7 @@ class PackageDocumentAction(DoxygenAction):
|
||||||
#file = textfile.TextFile(path)
|
#file = textfile.TextFile(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file = open(path, 'rb')
|
file = open(path, 'r')
|
||||||
except (IOError, OSError) as msg:
|
except (IOError, OSError) as msg:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
import plugins.EdkPlugins.basemodel.doxygen as doxygen
|
from ...basemodel import doxygen
|
||||||
import os
|
import os
|
||||||
try:
|
try:
|
||||||
import wx
|
import wx
|
||||||
|
@ -21,9 +21,9 @@ try:
|
||||||
except:
|
except:
|
||||||
gInGui = False
|
gInGui = False
|
||||||
import re
|
import re
|
||||||
import plugins.EdkPlugins.edk2.model.inf as inf
|
from ...edk2.model import inf
|
||||||
import plugins.EdkPlugins.edk2.model.dec as dec
|
from ...edk2.model import dec
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
_ignore_dir = ['.svn', '_svn', 'cvs']
|
_ignore_dir = ['.svn', '_svn', 'cvs']
|
||||||
_inf_key_description_mapping_table = {
|
_inf_key_description_mapping_table = {
|
||||||
|
@ -388,7 +388,7 @@ class PackageDocumentAction(DoxygenAction):
|
||||||
configFile.AddFile(path)
|
configFile.AddFile(path)
|
||||||
return
|
return
|
||||||
no = 0
|
no = 0
|
||||||
for no in xrange(len(lines)):
|
for no in range(len(lines)):
|
||||||
if len(lines[no].strip()) == 0:
|
if len(lines[no].strip()) == 0:
|
||||||
continue
|
continue
|
||||||
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
|
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
|
||||||
|
@ -1003,7 +1003,7 @@ class PackageDocumentAction(DoxygenAction):
|
||||||
#file = textfile.TextFile(path)
|
#file = textfile.TextFile(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file = open(path, 'rb')
|
file = open(path, 'r')
|
||||||
except (IOError, OSError) as msg:
|
except (IOError, OSError) as msg:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
|
|
||||||
import plugins.EdkPlugins.basemodel.ini as ini
|
from ...basemodel import ini
|
||||||
import re, os
|
import re, os
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
class DSCFile(ini.BaseINIFile):
|
class DSCFile(ini.BaseINIFile):
|
||||||
def GetSectionInstance(self, parent, name, isCombined=False):
|
def GetSectionInstance(self, parent, name, isCombined=False):
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
|
|
||||||
import plugins.EdkPlugins.basemodel.ini as ini
|
from ...basemodel import ini
|
||||||
import re, os
|
import re, os
|
||||||
from plugins.EdkPlugins.basemodel.message import *
|
from ...basemodel.message import *
|
||||||
|
|
||||||
class INFFile(ini.BaseINIFile):
|
class INFFile(ini.BaseINIFile):
|
||||||
_libobjs = {}
|
_libobjs = {}
|
||||||
|
|
Loading…
Reference in New Issue