Exemplo n.º 1
0
    def loadFromXML(xmlRoot, namespace, version, symbol):
        """loadFromXML:
                Loads a repeat variable from an XML definition.
                We do not trust the user and check every field (even mandatory).
        """
        logging.debug("[ RepeatVariable: loadFromXML:")
        if version == "0.1":
            xmlID = xmlRoot.get("id")
            xmlName = xmlRoot.get("name")
            xmlMutable = xmlRoot.get("mutable") == "True"
            xmlLearnable = xmlRoot.get("learnable") == "True"

            xmlChild = xmlRoot.find("{" + namespace + "}variable")
            child = AbstractVariable.loadFromXML(xmlChild, namespace, version, symbol)

            # minIterations
            xmlMinIterations = xmlRoot.find("{" + namespace + "}minIterations")
            if xmlMinIterations is not None:
                minIterations = int(xmlMinIterations.text)
            else:
                minIterations = 0

            # maxIterations
            xmlMaxIterations = xmlRoot.find("{" + namespace + "}maxIterations")
            if xmlMaxIterations is not None:
                maxIterations = int(xmlMaxIterations.text)
            else:
                maxIterations = RepeatVariable.MAX_ITERATIONS

            result = RepeatVariable(xmlID, xmlName, xmlMutable, xmlLearnable, child, minIterations, maxIterations)
            logging.debug("RepeatVariable: loadFromXML successes: {0} ]".format(result.toString()))
            return result
        logging.debug("RepeatVariable: loadFromXML fails")
        return None
Exemplo n.º 2
0
    def loadFromXML(xmlRoot, namespace, version, symbol):
        """loadFromXML:
                Loads an aggregate variable from an XML definition.
        """
        logging.debug("[ AggregateVariable: loadFromXML:")
        if version == "0.1":
            xmlID = xmlRoot.get("id")
            xmlName = xmlRoot.get("name")
            xmlMutable = xmlRoot.get("mutable") == "True"
            xmlLearnable = xmlRoot.get("learnable") == "True"

            result = AggregateVariable(xmlID, xmlName, xmlMutable, xmlLearnable, [])
            for xmlChildren in xmlRoot.findall("{" + namespace + "}variable"):
                child = AbstractVariable.loadFromXML(xmlChildren, namespace, version, symbol)
                result.addChild(child)
            logging.debug("AggregateVariable: loadFromXML successes: {0} ]".format(result.toString()))
            return result
        logging.debug("AggregateVariable: loadFromXML fails")
        return None
Exemplo n.º 3
0
    def loadFromXML(xmlRoot, namespace, version, symbol):
        """loadFromXML:
                Loads an alternate variable from an XML definition.
        """
        logging.debug("[ AlternateVariable: loadFromXML:")
        if version == "0.1":
            xmlID = xmlRoot.get("id")
            xmlName = xmlRoot.get("name")
            xmlMutable = xmlRoot.get("mutable") == "True"
            xmlLearnable = xmlRoot.get("learnable") == "True"

            result = AlternateVariable(xmlID, xmlName, xmlMutable, xmlLearnable, [])
            for xmlChildren in xmlRoot.findall("{" + namespace + "}variable"):
                child = AbstractVariable.loadFromXML(xmlChildren, namespace, version, symbol)
                result.addChild(child)

            logging.debug("AlternateVariable: loadFromXML successes: {0} ]".format(result.toString()))
            return result
        logging.debug("AlternateVariable: loadFromXML fails")
        return None
Exemplo n.º 4
0
    def loadFromXML(xmlRoot, namespace, version, symbol):
        """loadFromXML:
                Loads a repeat variable from an XML definition.
                We do not trust the user and check every field (even mandatory).
        """
        logging.debug("[ RepeatVariable: loadFromXML:")
        if version == "0.1":
            xmlID = xmlRoot.get("id")
            xmlName = xmlRoot.get("name")
            xmlMutable = xmlRoot.get("mutable") == "True"
            xmlLearnable = xmlRoot.get("learnable") == "True"

            xmlChild = xmlRoot.find("{" + namespace + "}variable")
            child = AbstractVariable.loadFromXML(xmlChild, namespace, version,
                                                 symbol)

            # minIterations
            xmlMinIterations = xmlRoot.find("{" + namespace + "}minIterations")
            if xmlMinIterations is not None:
                minIterations = int(xmlMinIterations.text)
            else:
                minIterations = 0

            # maxIterations
            xmlMaxIterations = xmlRoot.find("{" + namespace + "}maxIterations")
            if xmlMaxIterations is not None:
                maxIterations = int(xmlMaxIterations.text)
            else:
                maxIterations = RepeatVariable.MAX_ITERATIONS

            result = RepeatVariable(xmlID, xmlName, xmlMutable, xmlLearnable,
                                    child, minIterations, maxIterations)
            logging.debug(
                "RepeatVariable: loadFromXML successes: {0} ]".format(
                    result.toString()))
            return result
        logging.debug("RepeatVariable: loadFromXML fails")
        return None