本文整理汇总了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
示例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