]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Scripts / PackageDocumentTools / plugins / EdkPlugins / edk2 / model / doxygengen.py
index 94b6588c0ddf43ca2e29546919e1e8ee99c1938c..d0274d6afda8bab2da03ccb9b941c259d83349ce 100644 (file)
@@ -5,18 +5,12 @@
 #\r
 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-# This program and the accompanying materials are licensed and made available\r
-# under the terms and conditions of the BSD License which accompanies this\r
-# distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 """This file produce action class to generate doxygen document for edk2 codebase.\r
    The action classes are shared by GUI and command line tools.\r
 """\r
-import plugins.EdkPlugins.basemodel.doxygen as doxygen\r
+from plugins.EdkPlugins.basemodel import doxygen\r
 import os\r
 try:\r
     import wx\r
@@ -24,8 +18,8 @@ try:
 except:\r
     gInGui = False\r
 import re\r
-import plugins.EdkPlugins.edk2.model.inf as inf\r
-import plugins.EdkPlugins.edk2.model.dec as dec\r
+from plugins.EdkPlugins.edk2.model import inf\r
+from plugins.EdkPlugins.edk2.model import dec\r
 from plugins.EdkPlugins.basemodel.message import *\r
 \r
 _ignore_dir = ['.svn', '_svn', 'cvs']\r
@@ -376,9 +370,10 @@ class PackageDocumentAction(DoxygenAction):
             return\r
 \r
         try:\r
-            f = open(path, 'r')\r
-            lines = f.readlines()\r
-            f.close()\r
+            with open(path, 'r') as f:\r
+                lines = f.readlines()\r
+        except UnicodeDecodeError:\r
+            return\r
         except IOError:\r
             ErrorMsg('Fail to open file %s' % path)\r
             return\r
@@ -386,7 +381,7 @@ class PackageDocumentAction(DoxygenAction):
         configFile.AddFile(path)\r
 \r
         no = 0\r
-        for no in xrange(len(lines)):\r
+        for no in range(len(lines)):\r
             if len(lines[no].strip()) == 0:\r
                 continue\r
             if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:\r
@@ -1000,8 +995,8 @@ class PackageDocumentAction(DoxygenAction):
         #file = textfile.TextFile(path)\r
 \r
         try:\r
-            file = open(path, 'rb')\r
-        except (IOError, OSError), msg:\r
+            file = open(path, 'r')\r
+        except (IOError, OSError) as msg:\r
             return None\r
 \r
         t = file.read()\r