Salome HOME
Update list of known failed tests from testbase
[tools/configuration.git] / config / sconfig / salome_config.py
index b20b5bd2032433db8cbf01a815358eab8234a45a..a5faa746f4cffc7df7d56218f9fccfed96e10ada 100644 (file)
@@ -1,4 +1,22 @@
 #  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2016-2022  OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 
 """
 Manage SALOME configuration.
@@ -61,6 +79,7 @@ __all__ = [
     "commentAttr",
     "versionAttr",
     "urlAttr",
+    "sha1Attr",
     "supportedTags",
     "supportedAttributes",
     "tagAttributes",
@@ -126,6 +145,12 @@ def urlAttr():
     """
     return "url"
 
+def sha1Attr():
+    """
+    Return XML attribute for sha1 parameter (string).
+    """
+    return "sha1"
+
 def supportedTags():
     """
     Return list of all supported XML tags (list of strings).
@@ -136,7 +161,7 @@ def supportedAttributes():
     """
     Return list of all supported XML attributes (list of strings).
     """
-    return [nameAttr(), commentAttr(), versionAttr(), urlAttr()]
+    return [nameAttr(), commentAttr(), versionAttr(), urlAttr(), sha1Attr()]
     
 def tagAttributes(tag, force = False):
     """
@@ -173,6 +198,7 @@ def tagAttributes(tag, force = False):
         pass
         attrs[urlAttr()]      = False
         attrs[commentAttr()]  = False
+        attrs[sha1Attr()]     = False
     return attrs
 
 def tagChildren(tag):
@@ -243,6 +269,7 @@ class CfgTool(object):
         """
         self.enc = "utf-8"
         self.cfgFile = cfgFile if cfgFile else defaultConfFile()
+        self.parents = {}
         try:
             self.tree = ET.parse(self.cfgFile).getroot()
             self._checkConfig()
@@ -257,7 +284,7 @@ class CfgTool(object):
                 raise Exception("bad XML file %s: %s" % (self.cfgFile, str(e)))
             pass
         except Exception as e:
-            raise Exception("unkwnown error: %s" % str(e))
+            raise Exception("unknown error: %s" % str(e))
         pass
     
     def encoding(self):
@@ -468,7 +495,7 @@ class CfgTool(object):
         Return value is new XML element (xml.etree.ElementTree.Element).
         """
         child = ET.SubElement(elem, tag)
-        child._parent = elem # set parent!!!
+        self.parents[child] = elem # set parent!!!
         return child
 
     def _processTarget(self, target):
@@ -578,7 +605,7 @@ class CfgTool(object):
         path = []
         while elem is not None:
             path.append(_mkname(elem))
-            elem = elem._parent if hasattr(elem, "_parent") else None
+            elem = self.parents.get(elem)
             pass
         path.reverse()
         return pathSeparator().join(path)
@@ -711,7 +738,7 @@ class CfgTool(object):
             # check all childrens recursively
             children = elem.getchildren()
             for child in children:
-                child._parent = elem # set parent!!!
+                self.parents[child] = elem # set parent!!!
                 self._checkTag(child, elem.tag, errors)
                 pass
             pass