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:
Zhijux Fan
2018-12-17 00:04:04 +08:00
committed by Feng, Bob C
parent fe90631298
commit 7cc7e054f8
10 changed files with 39 additions and 39 deletions

View File

@ -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))
@ -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('<a class="el" href="files.html" target="basefrm">File List</a>') != -1:
lines[index] = "<!-- %s" % lines[index]
bfound = True
@ -969,7 +969,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'r')
text = fd.read()
fd.close()
except Exception, e:
except Exception as e:
self.LogMessage (" <<<Fail to open file %s" % path)
return
text = text.replace ('.s.dox', '.s')
@ -982,7 +982,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'w')
fd.write(text)
fd.close()
except Exception, e:
except Exception as e:
self.LogMessage (" <<<Fail to fixup file %s" % path)
return
self.LogMessage(' >>> Finish to fixup .dox postfix for file %s \n' % path)
@ -993,7 +993,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'r')
lines = fd.readlines()
fd.close()
except Exception, e:
except Exception as e:
self.LogMessage (" <<<Fail to open file %s" % path)
return
for line in lines:
@ -1004,7 +1004,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'w')
fd.write("".join(lines))
fd.close()
except Exception, e:
except Exception as e:
self.LogMessage (" <<<Fail to fixup file %s" % path)
return
self.LogMessage(' >>> Finish to fixup .decdoxygen postfix for file %s \n' % path)