BaseTools/Scripts: Porting PackageDocumentTools code to use Python3

Porting PackageDocumentTools code to Python3
DoxyGen 1.8.6
wxpython 4.0.3

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yunhua Feng
2018-08-28 17:00:24 +08:00
committed by Yonghong Zhu
parent c9486c8c9d
commit 9d7e1e56a7
12 changed files with 62 additions and 67 deletions

View File

@ -11,8 +11,6 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import print_function
from __future__ import absolute_import
import os
from .message import *
@ -67,7 +65,7 @@ class Page(BaseDoxygeItem):
def AddSection(self, 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):
if self.mIsMainPage:
@ -80,7 +78,7 @@ class Page(BaseDoxygeItem):
self.mText.append(self.mDescription)
endIndex = len(self.mText)
self.mSections.sort()
self.mSections.sort(key=lambda x: x.mName.lower())
for sect in self.mSections:
self.mText += sect.Generate()
@ -92,7 +90,7 @@ class Page(BaseDoxygeItem):
self.mText.insert(endIndex, '<ul>')
endIndex += 1
if self.mIsSort:
self.mSubPages.sort(cmp=lambda x, y: cmp(x.mName.lower(), y.mName.lower()))
self.mSubPages.sort(key=lambda x: x.mName.lower())
for page in self.mSubPages:
self.mText.insert(endIndex, '<li>\subpage %s \"%s\" </li>' % (page.mTag, page.mName))
endIndex += 1

View File

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import print_function
import array
import uuid
import re

View File

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import absolute_import
from .message import *
import re
import os
@ -25,7 +24,7 @@ class BaseINIFile(object):
@return: instance of this class
"""
if len(args) == 0: return object.__new__(cls, *args, **kwargs)
if len(args) == 0: return object.__new__(cls)
filename = args[0]
parent = None
if len(args) > 1:
@ -33,7 +32,7 @@ class BaseINIFile(object):
key = os.path.normpath(filename)
if key not in cls._objs.keys():
cls._objs[key] = object.__new__(cls, *args, **kwargs)
cls._objs[key] = object.__new__(cls)
if parent is not None:
cls._objs[key].AddParent(parent)

View File

@ -10,12 +10,12 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
import plugins.EdkPlugins.basemodel.ini as ini
import plugins.EdkPlugins.edk2.model.dsc as dsc
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
from ...basemodel import ini as ini
from ..model import dsc as dsc
from ..model import inf as inf
from ..model import dec as dec
import os
from plugins.EdkPlugins.basemodel.message import *
from ...basemodel.message import *
class SurfaceObject(object):
_objs = {}
@ -25,7 +25,7 @@ class SurfaceObject(object):
@return: instance of this class
"""
obj = object.__new__(cls, *args, **kwargs)
obj = object.__new__(cls)
if "None" not in cls._objs:
cls._objs["None"] = []
cls._objs["None"].append(obj)
@ -846,7 +846,7 @@ class SurfaceItem(object):
ErrorMsg("%s item is duplicated defined in packages: %s and %s" %
(name, parent.GetFilename(), cls._objs[name].GetParent().GetFilename()))
return None
obj = object.__new__(cls, *args, **kwargs)
obj = object.__new__(cls)
cls._objs[name] = obj
return obj
elif issubclass(parent.__class__, Module):

View File

@ -11,9 +11,9 @@
# 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
from plugins.EdkPlugins.basemodel.message import *
from ...basemodel.message import *
class DECFile(ini.BaseINIFile):

View File

@ -16,7 +16,7 @@
"""This file produce action class to generate doxygen document for edk2 codebase.
The action classes are shared by GUI and command line tools.
"""
import plugins.EdkPlugins.basemodel.doxygen as doxygen
from ...basemodel import doxygen
import os
try:
import wx
@ -24,9 +24,9 @@ try:
except:
gInGui = False
import re
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
from plugins.EdkPlugins.basemodel.message import *
from ..model import inf
from ..model import dec
from ...basemodel.message import *
_ignore_dir = ['.svn', '_svn', 'cvs']
_inf_key_description_mapping_table = {
@ -386,7 +386,7 @@ class PackageDocumentAction(DoxygenAction):
configFile.AddFile(path)
no = 0
for no in xrange(len(lines)):
for no in range(len(lines)):
if len(lines[no].strip()) == 0:
continue
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
@ -1000,7 +1000,7 @@ class PackageDocumentAction(DoxygenAction):
#file = textfile.TextFile(path)
try:
file = open(path, 'rb')
file = open(path, 'r')
except (IOError, OSError) as msg:
return None

View File

@ -13,7 +13,7 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
import plugins.EdkPlugins.basemodel.doxygen as doxygen
from ...basemodel import doxygen
import os
try:
import wx
@ -21,9 +21,9 @@ try:
except:
gInGui = False
import re
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
from plugins.EdkPlugins.basemodel.message import *
from ..model import inf
from ..model import dec
from ...basemodel.message import *
_ignore_dir = ['.svn', '_svn', 'cvs']
_inf_key_description_mapping_table = {
@ -388,7 +388,7 @@ class PackageDocumentAction(DoxygenAction):
configFile.AddFile(path)
return
no = 0
for no in xrange(len(lines)):
for no in range(len(lines)):
if len(lines[no].strip()) == 0:
continue
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
@ -1003,7 +1003,7 @@ class PackageDocumentAction(DoxygenAction):
#file = textfile.TextFile(path)
try:
file = open(path, 'rb')
file = open(path, 'r')
except (IOError, OSError) as msg:
return None

View File

@ -11,9 +11,9 @@
# 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
from plugins.EdkPlugins.basemodel.message import *
from ...basemodel.message import *
class DSCFile(ini.BaseINIFile):
def GetSectionInstance(self, parent, name, isCombined=False):

View File

@ -11,9 +11,9 @@
# 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
from plugins.EdkPlugins.basemodel.message import *
from ...basemodel.message import *
class INFFile(ini.BaseINIFile):
_libobjs = {}