ConfigTreeNode.py
changeset 1330 96b242e4c59d
parent 1315 ff14a66bbd12
child 1332 ac7d39f4e376
equal deleted inserted replaced
1328:a2f2981df9b0 1330:96b242e4c59d
    27             </xsd:complexType>
    27             </xsd:complexType>
    28           </xsd:element>
    28           </xsd:element>
    29         </xsd:schema>""")
    29         </xsd:schema>""")
    30 
    30 
    31 NameTypeSeparator = '@'
    31 NameTypeSeparator = '@'
       
    32 XSDSchemaErrorMessage = _("%s XML file doesn't follow XSD schema at line %d:\n%s")
    32 
    33 
    33 class ConfigTreeNode:
    34 class ConfigTreeNode:
    34     """
    35     """
    35     This class is the one that define confnodes.
    36     This class is the one that define confnodes.
    36     """
    37     """
   583         
   584         
   584         # Get the base xml tree
   585         # Get the base xml tree
   585         if self.MandatoryParams:
   586         if self.MandatoryParams:
   586             try:
   587             try:
   587                 basexmlfile = open(self.ConfNodeBaseXmlFilePath(CTNName), 'r')
   588                 basexmlfile = open(self.ConfNodeBaseXmlFilePath(CTNName), 'r')
   588                 self.BaseParams = etree.fromstring(
   589                 self.BaseParams, error = _BaseParamsParser.LoadXMLString(basexmlfile.read())
   589                     basexmlfile.read(), _BaseParamsParser)
   590                 if error is not None:
       
   591                     self.GetCTRoot().logger.write_warning(
       
   592                         XSDSchemaErrorMessage % ((CTNName + " BaseParams",) + error))
   590                 self.MandatoryParams = ("BaseParams", self.BaseParams)
   593                 self.MandatoryParams = ("BaseParams", self.BaseParams)
   591                 basexmlfile.close()
   594                 basexmlfile.close()
   592             except Exception, exc:
   595             except Exception, exc:
   593                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (CTNName, unicode(exc)))
   596                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (CTNName, unicode(exc)))
   594                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   597                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   595         
   598         
   596         # Get the xml tree
   599         # Get the xml tree
   597         if self.CTNParams:
   600         if self.CTNParams:
   598             try:
   601             try:
   599                 xmlfile = open(self.ConfNodeXmlFilePath(CTNName), 'r')
   602                 xmlfile = open(self.ConfNodeXmlFilePath(CTNName), 'r')
   600                 obj = etree.fromstring(xmlfile.read(), self.Parser)
   603                 obj, error = self.Parser.LoadXMLString(xmlfile.read())
       
   604                 if error is not None:
       
   605                     self.GetCTRoot().logger.write_warning(
       
   606                         XSDSchemaErrorMessage % ((CTNName,) + error))
   601                 name = obj.getLocalTag()
   607                 name = obj.getLocalTag()
   602                 setattr(self, name, obj)
   608                 setattr(self, name, obj)
   603                 self.CTNParams = (name, obj)
   609                 self.CTNParams = (name, obj)
   604                 xmlfile.close()
   610                 xmlfile.close()
   605             except Exception, exc:
   611             except Exception, exc: