]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/Exception.py
BaseTools: Use absolute import in Ecc
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / Exception.py
index ff8736059f77f9e42eae99d2c2c5d55ede887a8b..340e0e975207d537420176a481e5740518b8adb4 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to parse exception items found by ECC tool\r
 #\r
-# Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 ##\r
 # Import Modules\r
 #\r
-from Common.XmlRoutines import *\r
-import os.path\r
+from __future__ import print_function\r
+from __future__ import absolute_import\r
+from .Xml.XmlRoutines import *\r
+import Common.LongFilePathOs as os\r
 \r
 # ExceptionXml to parse Exception Node of XML file\r
 class ExceptionXml(object):\r
@@ -23,12 +25,12 @@ class ExceptionXml(object):
         self.KeyWord = ''\r
         self.ErrorID = ''\r
         self.FilePath = ''\r
-        \r
+\r
     def FromXml(self, Item, Key):\r
         self.KeyWord = XmlElement(Item, '%s/KeyWord' % Key)\r
         self.ErrorID = XmlElement(Item, '%s/ErrorID' % Key)\r
         self.FilePath = os.path.normpath(XmlElement(Item, '%s/FilePath' % Key))\r
-        \r
+\r
     def __str__(self):\r
         return 'ErrorID = %s KeyWord = %s FilePath = %s' %(self.ErrorID, self.KeyWord, self.FilePath)\r
 \r
@@ -36,22 +38,22 @@ class ExceptionXml(object):
 class ExceptionListXml(object):\r
     def __init__(self):\r
         self.List = []\r
-    \r
+\r
     def FromXmlFile(self, FilePath):\r
         XmlContent = XmlParseFile(FilePath)\r
         for Item in XmlList(XmlContent, '/ExceptionList/Exception'):\r
             Exp = ExceptionXml()\r
             Exp.FromXml(Item, 'Exception')\r
             self.List.append(Exp)\r
-    \r
+\r
     def ToList(self):\r
         RtnList = []\r
         for Item in self.List:\r
             #RtnList.append((Item.ErrorID, Item.KeyWord, Item.FilePath))\r
             RtnList.append((Item.ErrorID, Item.KeyWord))\r
-    \r
+\r
         return RtnList\r
-        \r
+\r
     def __str__(self):\r
         RtnStr = ''\r
         if self.List:\r
@@ -70,9 +72,9 @@ class ExceptionCheck(object):
         if FilePath and os.path.isfile(FilePath):\r
             self.ExceptionListXml.FromXmlFile(FilePath)\r
             self.ExceptionList = self.ExceptionListXml.ToList()\r
-    \r
+\r
     def IsException(self, ErrorID, KeyWord, FileID=-1):\r
-        if (str(ErrorID), KeyWord) in self.ExceptionList:\r
+        if (str(ErrorID), KeyWord.replace('\r\n', '\n')) in self.ExceptionList:\r
             return True\r
         else:\r
             return False\r
@@ -84,4 +86,4 @@ class ExceptionCheck(object):
 #\r
 if __name__ == '__main__':\r
     El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')\r
-    print El.ExceptionList\r
+    print(El.ExceptionList)\r