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


Python AbstractVariable.toString方法代码示例

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


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

示例1: toString

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
 def toString(self):
     """toString:
     """
     lgth = 0
     if self.getChildren() is not None:
         lgth = len(self.getChildren())
     return _("[Aggregate] {0} ({1})").format(AbstractVariable.toString(self), str(lgth))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:9,代码来源:AggregateVariable.py

示例2: read

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def read(self, readingToken):
        """read:
                Each child tries sequentially to read a part of the read value.
                If one of them fails, the whole operation is cancelled.
        """
        self.log.debug("[ {0} (Aggregate): read access:".format(AbstractVariable.toString(self)))
        if self.getChildren() is not None:
            if self.isMutable():
                # mutable.
                self.sortChildrenToRead(readingToken)
                self.readChildren(readingToken)
            else:
                # not mutable.
                self.readChildren(readingToken)

        else:
            # no child.
            self.log.debug("Write abort: the variable has no child.")
            readingToken.setOk(False)

        # Variable notification
        if readingToken.isOk():
            self.notifyBoundedVariables("read", readingToken, self.currentValue)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), readingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:27,代码来源:AggregateVariable.py

示例3: notifiedRead

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def notifiedRead(self, readingToken, pointedValue):
        """notifiedRead:
                A read access called by a notification of the pointed variable (when it has finished its own treatment).
                It checks that the new value complies with the reading token value at this very position.

                @type readingToken: netzob.Common.MMSTD.Dictionary.VariableProcessingToken.VariableReadingToken.VariableReadingToken
                @param readingToken: a token which contains all critical information on this access.
        """
        self.log.debug("[ {0} (relation): read access:".format(AbstractVariable.toString(self)))

        if self.isDefined(readingToken):
            for linkedValue in readingToken.getLinkedValue():
                if linkedValue[0] == self.getID():
                    # We compare the pointed value to the value the current variable wrote in memory.
                    if linkedValue[1] != self.computeValue(pointedValue):
                        readingToken.setOk(False)
                        break

        else:
            self.log.debug("Read abort: the variable is neither defined, nor mutable.")
            readingToken.setOk(False)

        # Variable notification
        if readingToken.isOk():
            self.notifyBoundedVariables("read", readingToken, pointedValue)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), readingToken.toString()))
开发者ID:lindi2,项目名称:netzob,代码行数:29,代码来源:ComputedRelationVariable.py

示例4: notifiedWrite

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def notifiedWrite(self, writingToken):
        """notify:
                A write access called by a notification of the pointed variable (when it has finished its own treatment).
                It updates the values this variable has written in the writingToken value.

                @type writingToken: netzob.Common.MMSTD.Dictionary.VariableProcessingToken.VariableWritingToken.VariableWritingToken
                @param writingToken: a token which contains all critical information on this access.
        """
        self.log.debug("[ {0} (relation): notifiedWrite access:".format(AbstractVariable.toString(self)))

        if self.isDefined(writingToken):

            # Compute the value
            self.retrieveValue(writingToken)

            # replace the new value in the writing token
            writingToken.setValueForVariable(self, self.currentValue)

        else:
            self.log.debug("Write abort: the variable is neither defined, nor random.")
            writingToken.setOk(False)

        # Variable notification
        if writingToken.isOk():
            self.notifyBoundedVariables("write", writingToken)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), writingToken.toString()))
开发者ID:lindi2,项目名称:netzob,代码行数:29,代码来源:ComputedRelationVariable.py

示例5: read

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def read(self, readingToken):
        """read:
                The relation variable tries to compare/learn the read value.
        """
        self.log.debug("[ {0} (relation): read access:".format(AbstractVariable.toString(self)))
        self.directPointer = self.findDirectPointer()

        if self.isDefined(readingToken):
            if self.directPointer:
                # We directly retrieve and compare the value.
                self.retrieveValue(readingToken)
                self.compare(readingToken)
            else:
                # We make a small format comparison.
                self.compareFormat(readingToken)
                # We will verify the value at notification time.
                self.bindValue(readingToken)

        else:
            self.log.debug("Read abort: the variable is not defined.")
            readingToken.setOk(False)

        # Variable notification
        if readingToken.isOk():
            self.notifyBoundedVariables("read", readingToken, self.currentValue)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), readingToken.toString()))
开发者ID:lindi2,项目名称:netzob,代码行数:29,代码来源:ComputedRelationVariable.py

示例6: write

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def write(self, writingToken):
        """write:
                The relation variable returns a computed or a generated value.
        """
        self.log.debug("[ {0} (relation): write access:".format(AbstractVariable.toString(self)))
        self.directPointer = self.findDirectPointer()

        if self.isDefined(writingToken):
            if not self.directPointer:
                # We will write the real value at notification time. (An awaiting value is written though.)
                self.bindValue(writingToken)
                self.guessValue()
            else:
                # We directly retrieve and write the actual value (which would be deprecated and replaced if the variable is directPointer).
                self.retrieveValue(writingToken)
            self.writeValue(writingToken)
        else:
            self.log.debug("Write abort: the variable is not defined.")
            writingToken.setOk(False)

        # Variable notification
        if writingToken.isOk():
            self.notifyBoundedVariables("write", writingToken)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), writingToken.toString()))
开发者ID:lindi2,项目名称:netzob,代码行数:27,代码来源:ComputedRelationVariable.py

示例7: toString

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
 def toString(self):
     """toString:
     """
     lgth = 0
     if self.children is not None:
         lgth = len(self.children)
     return _("[Alternate] {0} ({1})").format(AbstractVariable.toString(self), str(lgth))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:9,代码来源:AlternateVariable.py

示例8: writeChildren

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def writeChildren(self, writingToken):
        """write:
                Each child tries to write its value..
                If it fails, it restore it value and the next child try.
                It stops if one child successes.
        """
        self.log.debug("[ {0} (Alternate): writeChildren:".format(AbstractVariable.toString(self)))

        savedValue = writingToken.getValue()
        savedIndex = writingToken.getIndex()
        for child in self.getChildren():
            # Memorized values for the child and its successor.
            dictOfValues = dict()
            dictOfValue = child.getDictOfValues(writingToken)
            for key, val in dictOfValue.iteritems():
                dictOfValues[key] = val

            child.write(writingToken)
            if writingToken.isOk() and writingToken.getValue() is not None:
                break
            else:
                writingToken.setValue(savedValue)

                # We restore values for the child and its successor.
                child.restore(writingToken)
                vocabulary = writingToken.getVocabulary()
                for key, val in dictOfValues.iteritems():
                    vocabulary.getVariableByID(key).setCurrentValue(val)

        if writingToken.isOk():
            # The value of the variable is simply the value we made.
            self.currentValue = writingToken.getValue()[savedIndex:writingToken.getIndex()]

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), writingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:36,代码来源:AlternateVariable.py

示例9: write

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def write(self, writingToken):
        """write:
                Each child tries sequentially to write its value.
                If one of them fails, the whole operation is cancelled.
        """
        self.log.debug("[ {0} (Aggregate): write access:".format(AbstractVariable.toString(self)))
        self.resetTokenChoppedIndexes()  # New write access => new final value and new reference to it.
        if self.getChildren() is not None:
            if self.isMutable():
                # mutable.
                self.shuffleChildren()
                self.writeChildren(writingToken)

            else:
                # not mutable.
                self.writeChildren(writingToken)

        else:
            # no child.
            self.log.debug("Write abort: the variable has no child.")
            writingToken.setOk(False)

        # Variable notification
        if writingToken.isOk():
            self.notifyBoundedVariables("write", writingToken)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), writingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:29,代码来源:AggregateVariable.py

示例10: write

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def write(self, writingToken):
        """write:
                The leaf element returns its value or a generated one.
        """
        self.log.debug("[ {0} (leaf): write access:".format(AbstractVariable.toString(self)))
        self.resetTokenChoppedIndexes()  # New write access => new final value and new reference to it.
        if self.isMutable():
            if self.isLearnable():
                if self.isDefined(writingToken):
                    # mutable, learnable and defined.
                    self.mutate(writingToken)
                    self.writeValue(writingToken)

                else:
                    # mutable, learnable and not defined.
                    self.generate(writingToken)
                    self.memorize(writingToken)
                    self.writeValue(writingToken)
            else:
                if self.isDefined(writingToken):
                    # mutable, not learnable, defined.
                    self.generate(writingToken)
                    self.writeValue(writingToken)

                else:
                    # mutable, not learnable, not defined.
                    self.generate(writingToken)
                    self.writeValue(writingToken)

        else:
            if self.isLearnable():
                if self.isDefined(writingToken):
                    # not mutable, learnable and defined.
                    self.writeValue(writingToken)

                else:
                    # not mutable, learnable and not defined.
                    self.generate(writingToken)
                    self.memorize(writingToken)
                    self.writeValue(writingToken)

            else:
                if self.isDefined(writingToken):
                    # not mutable, not learnable and defined.
                    self.writeValue(writingToken)

                else:
                    # not mutable, not learnable and not defined.
                    self.log.debug("Write abort: the variable is neither defined, nor mutable.")
                    writingToken.setOk(False)

        # Variable notification
        if writingToken.isOk():
            self.notifyBoundedVariables("write", writingToken)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), writingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:58,代码来源:AbstractLeafVariable.py

示例11: read

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def read(self, readingToken):
        """read:
                The leaf element tries to compare/learn the read value.
        """
        self.log.debug("[ {0} (leaf): read access:".format(AbstractVariable.toString(self)))
        if self.isMutable():
            if self.isLearnable():
                if self.isDefined(readingToken):
                    # mutable, learnable and defined.
                    self.forget(readingToken)
                    self.compareFormat(readingToken)
                    self.learn(readingToken)
                    self.memorize(readingToken)

                else:
                    # mutable, learnable and not defined.
                    self.compareFormat(readingToken)
                    self.learn(readingToken)
                    self.memorize(readingToken)

            else:
                if self.isDefined(readingToken):
                    # mutable, not learnable and defined.
                    self.compareFormat(readingToken)

                else:
                    # mutable, learnable and not defined.
                    self.compareFormat(readingToken)

        else:
            if self.isLearnable():
                if self.isDefined(readingToken):
                    # not mutable, learnable and defined.
                    self.compare(readingToken)

                else:
                    # not mutable, learnable and not defined.
                    self.compareFormat(readingToken)
                    self.learn(readingToken)
                    self.memorize(readingToken)

            else:
                if self.isDefined(readingToken):
                    # not mutable, not learnable and defined.
                    self.compare(readingToken)

                else:
                    # not mutable, not learnable and not defined.
                    self.log.debug("Read abort: the variable is neither defined, nor mutable.")
                    readingToken.setOk(False)

        # Variable notification
        if readingToken.isOk():
            self.notifyBoundedVariables("read", readingToken, self.getValue(readingToken))

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), readingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:58,代码来源:AbstractLeafVariable.py

示例12: toString

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def toString(self):
        """toString:
                For debugging purpose.
        """
        # We simply avoid to print unreadable binary.
        if self.type.getType() == BinaryType.TYPE:
            readableValue = TypeConvertor.bin2strhex(self.originalValue)
        else:
            readableValue = self.bin2str(self.originalValue)

        return "[Data] {0}, type: {1}, original value: {2}".format(AbstractVariable.toString(self), self.type.toString(), readableValue)
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:13,代码来源:DataVariable.py

示例13: toXML

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def toXML(self, root, namespace):
        """toXML:
            Creates the xml tree associated to this variable.
            Adds every child's own xml definition as xml child to this tree.
        """
        self.log.debug("[ {0} (Aggregate): toXML:".format(AbstractVariable.toString(self)))
        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:AggregateVariable")
        xmlVariable.set("mutable", str(self.isMutable()))
        xmlVariable.set("learnable", str(self.isLearnable()))

        # Definition of children variables
        for child in self.getChildren():
            child.toXML(xmlVariable, namespace)
        self.log.debug("Variable {0}. ]".format(self.getName()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:19,代码来源:AggregateVariable.py

示例14: readChildren

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
    def readChildren(self, readingToken):
        """read:
                Each child tries to read the value.
                If it fails, it restore it value and the next child try.
                It stops if one child successes.
        """
        self.log.debug("[ {0} (Alternate): readChildren:".format(AbstractVariable.toString(self)))
        savedIndex = readingToken.getIndex()
        for child in self.getChildren():
            # Memorized values for the child and its successors.
            dictOfValues = dict()
            dictOfValue = child.getDictOfValues(readingToken)
            for key, val in dictOfValue.iteritems():
                dictOfValues[key] = val

            child.read(readingToken)
            if readingToken.isOk():
                break
            else:
                readingToken.setIndex(savedIndex)

                # We restore values for the child and its successors.
                child.restore(readingToken)
                vocabulary = readingToken.getVocabulary()
                for key, val in dictOfValues.iteritems():
                    vocabulary.getVariableByID(key).setCurrentValue(val)

        if readingToken.isOk():
            # The value of the variable is simply the value we 'ate'.
            self.currentValue = readingToken.getValue()[savedIndex:readingToken.getIndex()]

        if self.isLearnable() and not readingToken.isOk() and not self.isLearning():
            # If we dont not found a proper child but the node can learn, we learn the value.
            self.learn(child, readingToken)

        self.log.debug("Variable {0}: {1}. ]".format(self.getName(), readingToken.toString()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:38,代码来源:AlternateVariable.py

示例15: toString

# 需要导入模块: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable import AbstractVariable [as 别名]
# 或者: from netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable import toString [as 别名]
 def toString(self):
     """toString:
     """
     return "[Repeat] {0}, iterations: ({1}, {2})".format(AbstractVariable.toString(self), str(self.minIterations), str(self.maxIterations))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:6,代码来源:RepeatVariable.py


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