summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Ecc/Exception.py
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2024-06-04 06:43:08 +0300
committerkx <kx@radix.pro>2024-06-04 06:43:08 +0300
commit7e2ccccace24636f29ddc210b94606abd4c7e42b (patch)
tree545d43ea12671048956cafeb12303e84d601e571 /BaseTools/Source/Python/Ecc/Exception.py
parent27b044605cd5f6b33a3d231576003850b3fe305b (diff)
downloadedk2-trunk.tar.xz
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'BaseTools/Source/Python/Ecc/Exception.py')
-rw-r--r--BaseTools/Source/Python/Ecc/Exception.py166
1 files changed, 83 insertions, 83 deletions
diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py
index 9251b8d7c4..1c2320fe44 100644
--- a/BaseTools/Source/Python/Ecc/Exception.py
+++ b/BaseTools/Source/Python/Ecc/Exception.py
@@ -1,83 +1,83 @@
-## @file
-# This file is used to parse exception items found by ECC tool
-#
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-##
-# Import Modules
-#
-from __future__ import print_function
-from __future__ import absolute_import
-from Ecc.Xml.XmlRoutines import *
-import Common.LongFilePathOs as os
-
-# ExceptionXml to parse Exception Node of XML file
-class ExceptionXml(object):
- def __init__(self):
- self.KeyWord = ''
- self.ErrorID = ''
- self.FilePath = ''
-
- def FromXml(self, Item, Key):
- self.KeyWord = XmlElement(Item, '%s/KeyWord' % Key)
- self.ErrorID = XmlElement(Item, '%s/ErrorID' % Key)
- self.FilePath = os.path.normpath(XmlElement(Item, '%s/FilePath' % Key))
-
- def __str__(self):
- return 'ErrorID = %s KeyWord = %s FilePath = %s' %(self.ErrorID, self.KeyWord, self.FilePath)
-
-# ExceptionListXml to parse Exception Node List of XML file
-class ExceptionListXml(object):
- def __init__(self):
- self.List = []
-
- def FromXmlFile(self, FilePath):
- XmlContent = XmlParseFile(FilePath)
- for Item in XmlList(XmlContent, '/ExceptionList/Exception'):
- Exp = ExceptionXml()
- Exp.FromXml(Item, 'Exception')
- self.List.append(Exp)
-
- def ToList(self):
- RtnList = []
- for Item in self.List:
- #RtnList.append((Item.ErrorID, Item.KeyWord, Item.FilePath))
- RtnList.append((Item.ErrorID, Item.KeyWord))
-
- return RtnList
-
- def __str__(self):
- RtnStr = ''
- if self.List:
- for Item in self.List:
- RtnStr = RtnStr + str(Item) + '\n'
- return RtnStr
-
-# A class to check exception
-class ExceptionCheck(object):
- def __init__(self, FilePath = None):
- self.ExceptionList = []
- self.ExceptionListXml = ExceptionListXml()
- self.LoadExceptionListXml(FilePath)
-
- def LoadExceptionListXml(self, FilePath):
- if FilePath and os.path.isfile(FilePath):
- self.ExceptionListXml.FromXmlFile(FilePath)
- self.ExceptionList = self.ExceptionListXml.ToList()
-
- def IsException(self, ErrorID, KeyWord, FileID=-1):
- if (str(ErrorID), KeyWord.replace('\r\n', '\n')) in self.ExceptionList:
- return True
- else:
- return False
-
-##
-#
-# This acts like the main() function for the script, unless it is 'import'ed into another
-# script.
-#
-if __name__ == '__main__':
- El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')
- print(El.ExceptionList)
+## @file
+# This file is used to parse exception items found by ECC tool
+#
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import print_function
+from __future__ import absolute_import
+from Ecc.Xml.XmlRoutines import *
+import Common.LongFilePathOs as os
+
+# ExceptionXml to parse Exception Node of XML file
+class ExceptionXml(object):
+ def __init__(self):
+ self.KeyWord = ''
+ self.ErrorID = ''
+ self.FilePath = ''
+
+ def FromXml(self, Item, Key):
+ self.KeyWord = XmlElement(Item, '%s/KeyWord' % Key)
+ self.ErrorID = XmlElement(Item, '%s/ErrorID' % Key)
+ self.FilePath = os.path.normpath(XmlElement(Item, '%s/FilePath' % Key))
+
+ def __str__(self):
+ return 'ErrorID = %s KeyWord = %s FilePath = %s' %(self.ErrorID, self.KeyWord, self.FilePath)
+
+# ExceptionListXml to parse Exception Node List of XML file
+class ExceptionListXml(object):
+ def __init__(self):
+ self.List = []
+
+ def FromXmlFile(self, FilePath):
+ XmlContent = XmlParseFile(FilePath)
+ for Item in XmlList(XmlContent, '/ExceptionList/Exception'):
+ Exp = ExceptionXml()
+ Exp.FromXml(Item, 'Exception')
+ self.List.append(Exp)
+
+ def ToList(self):
+ RtnList = []
+ for Item in self.List:
+ #RtnList.append((Item.ErrorID, Item.KeyWord, Item.FilePath))
+ RtnList.append((Item.ErrorID, Item.KeyWord))
+
+ return RtnList
+
+ def __str__(self):
+ RtnStr = ''
+ if self.List:
+ for Item in self.List:
+ RtnStr = RtnStr + str(Item) + '\n'
+ return RtnStr
+
+# A class to check exception
+class ExceptionCheck(object):
+ def __init__(self, FilePath = None):
+ self.ExceptionList = []
+ self.ExceptionListXml = ExceptionListXml()
+ self.LoadExceptionListXml(FilePath)
+
+ def LoadExceptionListXml(self, FilePath):
+ if FilePath and os.path.isfile(FilePath):
+ self.ExceptionListXml.FromXmlFile(FilePath)
+ self.ExceptionList = self.ExceptionListXml.ToList()
+
+ def IsException(self, ErrorID, KeyWord, FileID=-1):
+ if (str(ErrorID), KeyWord.replace('\r\n', '\n')) in self.ExceptionList:
+ return True
+ else:
+ return False
+
+##
+#
+# This acts like the main() function for the script, unless it is 'import'ed into another
+# script.
+#
+if __name__ == '__main__':
+ El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')
+ print(El.ExceptionList)