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


Python TypeConvertor.bin2hexstring方法代码示例

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


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

示例1: toXML

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bin2hexstring [as 别名]
    def toXML(self, root, namespace):
        """toXML:
            Create the xml tree associated to this variable.
        """
        self.log.debug("[ {0}: toXML:".format(self.toString()))
        xmlVariable = etree.SubElement(root, "{" + namespace + "}variable")
        xmlVariable.set("id", str(self.getID()))
        xmlVariable.set("name", str(self.getName()))
        xmlVariable.set("{http://www.w3.org/2001/XMLSchema-instance}type", "netzob:ComputedRelationVariable")
        xmlVariable.set("mutable", str(self.isMutable()))
        xmlVariable.set("learnable", str(self.isLearnable()))

        # sized
        xmlSized = etree.SubElement(xmlVariable, "{" + namespace + "}sized")
        xmlSized.text = str(self.relationType.getAssociatedDataType().isSized())

        # type
        xmlType = etree.SubElement(xmlVariable, "{" + namespace + "}type")
        xmlType.text = self.relationType.getType()

        # Definition of the referenced variable ID.
        xmlRefID = etree.SubElement(xmlVariable, "{" + namespace + "}ref")
        xmlRefID.text = str(self.pointedID)
        self.log.debug("Variable {0}. ]".format(self.getName()))

        # minChars
        xmlMinChars = etree.SubElement(xmlVariable, "{" + namespace + "}minChars")
        xmlMinChars.text = str(self.relationType.getAssociatedDataType().getMinChars())

        # maxChars
        xmlMaxChars = etree.SubElement(xmlVariable, "{" + namespace + "}maxChars")
        xmlMaxChars.text = str(self.relationType.getAssociatedDataType().getMaxChars())

        # delimiter
        xmlDelimiter = etree.SubElement(xmlVariable, "{" + namespace + "}delimiter")
        xmlDelimiter.text = str(TypeConvertor.bin2hexstring(self.relationType.getAssociatedDataType().getDelimiter()))

        # factor
        xmlFactor = etree.SubElement(xmlVariable, "{" + namespace + "}factor")
        xmlFactor.text = str(self.relationType.getFactor())

        # offset
        xmlOffset = etree.SubElement(xmlVariable, "{" + namespace + "}offset")
        xmlOffset.text = str(self.relationType.getOffset())
开发者ID:sangyf,项目名称:netzob,代码行数:46,代码来源:ComputedRelationVariable.py

示例2: toXML

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bin2hexstring [as 别名]
    def toXML(self, root, namespace):
        """toXML:
            Creates the xml tree associated to this variable.
        """
        self.log.debug("- {0}: toXML:".format(self.toString()))
        xmlVariable = etree.SubElement(root, "{" + namespace + "}variable")
        xmlVariable.set("id", str(self.getID()))
        xmlVariable.set("name", str(self.getName()))
        xmlVariable.set("{http://www.w3.org/2001/XMLSchema-instance}type", "netzob:DataVariable")
        xmlVariable.set("mutable", str(self.isMutable()))
        xmlVariable.set("learnable", str(self.isLearnable()))

        # sized
        xmlSized = etree.SubElement(xmlVariable, "{" + namespace + "}sized")
        xmlSized.text = str(self.type.isSized())

        # type
        xmlType = etree.SubElement(xmlVariable, "{" + namespace + "}type")
        xmlType.text = self.type.getType()

        # originalValue (can be None)
        if self.originalValue is not None and self.isMutable() is not None:  # We do not memorize random values.
            xmlOriginalValue = etree.SubElement(xmlVariable, "{" + namespace + "}originalValue")
            # We memorize the current value as the future original value.
            # I assume that the user want the last current value (that he may have hand-edited) of the variable to be memorized.
            xmlOriginalValue.text = self.type.bin2str(self.currentValue)

        # minChars
        xmlMinChars = etree.SubElement(xmlVariable, "{" + namespace + "}minChars")
        xmlMinChars.text = str(self.type.getMinChars())

        # maxBits
        xmlMaxChars = etree.SubElement(xmlVariable, "{" + namespace + "}maxChars")
        xmlMaxChars.text = str(self.type.getMaxChars())

        # delimiter
        xmlDelimiter = etree.SubElement(xmlVariable, "{" + namespace + "}delimiter")
        xmlDelimiter.text = str(TypeConvertor.bin2hexstring(self.type.getDelimiter()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:40,代码来源:DataVariable.py


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