本文整理汇总了Python中netzob.Common.Type.TypeConvertor.TypeConvertor.bitarray2StrBitarray方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvertor.bitarray2StrBitarray方法的具体用法?Python TypeConvertor.bitarray2StrBitarray怎么用?Python TypeConvertor.bitarray2StrBitarray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netzob.Common.Type.TypeConvertor.TypeConvertor
的用法示例。
在下文中一共展示了TypeConvertor.bitarray2StrBitarray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bitarray2StrBitarray [as 别名]
def computeCurrentValue(self, binValue):
if binValue != None:
strCurrentValue = TypeConvertor.bitarray2StrBitarray(binValue)
binCurrentValue = binValue
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例2: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bitarray2StrBitarray [as 别名]
def computeCurrentValue(self, binValue):
"""computeCurrentValue:
Compute a couple of binary and string values for the current variable.
@type strValue: string
@param strValue: a string value proposed as default value for this variable.
"""
if binValue is not None:
strCurrentValue = TypeConvertor.bitarray2StrBitarray(binValue)
binCurrentValue = binValue
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例3: toXML
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bitarray2StrBitarray [as 别名]
def toXML(self, root, namespace):
xmlVariable = etree.SubElement(root, "{" + namespace + "}variable")
# Header specific to the definition of a variable
xmlVariable.set("id", str(self.getID()))
xmlVariable.set("name", str(self.getName()))
xmlVariable.set("{http://www.w3.org/2001/XMLSchema-instance}type", "netzob:BinaryVariable")
# Original Value
if self.getOriginalValue() != None:
xmlBinaryVariableOriginalValue = etree.SubElement(xmlVariable, "{" + namespace + "}originalValue")
xmlBinaryVariableOriginalValue.text = TypeConvertor.bitarray2StrBitarray(self.getOriginalValue())
# Minimum bits
xmlBinaryVariableStartValue = etree.SubElement(xmlVariable, "{" + namespace + "}minBits")
xmlBinaryVariableStartValue.text = str(self.getMinBits())
# Maximum bits
xmlBinaryVariableEndValue = etree.SubElement(xmlVariable, "{" + namespace + "}maxBits")
xmlBinaryVariableEndValue.text = str(self.getMaxBits())
示例4: getValueToSend
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bitarray2StrBitarray [as 别名]
def getValueToSend(self, negative, vocabulary, memory):
if self.getCurrentValue() != None:
self.log.debug("BINARY : HAS CURRENT VALUE")
return self.getCurrentValue()
if memory.hasMemorized(self):
self.log.debug("BINARY : HAS NO CURRENT VALUE BUT HAS MEMORY")
return memory.recall(self)
# We generate a new value
binNewValue = self.generateValue()
strNewValue = TypeConvertor.bitarray2StrBitarray(self.generateValue())
newValue = (binNewValue, strNewValue)
# We save in memory the current value
memory.memorize(self, newValue)
# We return the newly generated and memorized value
return newValue
示例5: getValueToSend
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bitarray2StrBitarray [as 别名]
def getValueToSend(self, negative, vocabulary, memory):
"""getValueToSend:
Get the current value of the variable it can be the original value if its set and not forget or the value in memory if it has one or it generates one and save its value in memory.
"""
if self.getCurrentValue() is not None:
self.log.debug("BINARY : HAS CURRENT VALUE")
return self.getCurrentValue()
if memory.hasMemorized(self):
self.log.debug("BINARY : HAS NO CURRENT VALUE BUT HAS MEMORY")
return memory.recall(self)
# We generate a new value
binNewValue = self.generateValue()
strNewValue = TypeConvertor.bitarray2StrBitarray(self.generateValue())
newValue = (binNewValue, strNewValue)
# We save in memory the current value
memory.memorize(self, newValue)
# We return the newly generated and memorized value
return newValue