当前位置: 首页>>代码示例>>Python>>正文


Python AbstractVariable.loadFromXML方法代码示例

本文整理汇总了Python中netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable.loadFromXML方法的典型用法代码示例。如果您正苦于以下问题:Python AbstractVariable.loadFromXML方法的具体用法?Python AbstractVariable.loadFromXML怎么用?Python AbstractVariable.loadFromXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable的用法示例。


在下文中一共展示了AbstractVariable.loadFromXML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadFromXML

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import loadFromXML [as 别名]
    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
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:36,代码来源:RepeatVariable.py

示例2: loadFromXML

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import loadFromXML [as 别名]
    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
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:21,代码来源:AggregateVariable.py


注:本文中的netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable.loadFromXML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。