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


Python TypeConvertor.str2bool方法代码示例

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


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

示例1: loadFromXML

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import str2bool [as 别名]
    def loadFromXML(xmlRoot, namespace, version, automata, vocabulary):
        if version == "0.1":

            id = xmlRoot.get('id')
            name = xmlRoot.get('name')
            initiator = TypeConvertor.str2bool(xmlRoot.get('initiator'))

            abstractionLayer = None
            if xmlRoot.find("{" + namespace + "}abstractionLayer") is not None:
                abstractionLayer = AbstractionLayer.loadFromXML(xmlRoot.find("{" + namespace + "}abstractionLayer"), namespace, version, vocabulary)

            return MMSTDVisitor(id, name, automata, initiator, abstractionLayer)

        return None
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:16,代码来源:MMSTDVisitor.py

示例2: loadProperties

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import str2bool [as 别名]
    def loadProperties(rootElement, namespace):
        # Retrieves the direction
        msg_direction = rootElement.find("{" + namespace + "}direction").text

        # Retrieves the major
        msg_major = rootElement.find("{" + namespace + "}major").text

        # Retrieves the minor
        msg_minor = int(rootElement.find("{" + namespace + "}minor").text)

        # Retrieves the requestMode
        msg_requestMode = rootElement.find("{" + namespace + "}requestMode").text

        # Retrieves the pid
        msg_pid = int(rootElement.find("{" + namespace + "}pid").text)

        # Retrieves the status
        msg_status = int(rootElement.find("{" + namespace + "}status").text)

        # Retrieves the information
        msg_information = long(rootElement.find("{" + namespace + "}information").text)

        # Retrieves the cancel
        msg_cancel = TypeConvertor.str2bool(rootElement.find("{" + namespace + "}cancel").text)

        # Retrieves the sizeIn
        msg_sizeIn = int(rootElement.find("{" + namespace + "}sizeIn").text)

        # Retrieves the sizeOut
        msg_sizeOut = int(rootElement.find("{" + namespace + "}sizeOut").text)

        return (
            msg_direction,
            msg_major,
            msg_minor,
            msg_requestMode,
            msg_pid,
            msg_status,
            msg_information,
            msg_cancel,
            msg_sizeIn,
            msg_sizeOut,
        )
开发者ID:sangyf,项目名称:netzob,代码行数:45,代码来源:IRPMessageFactory.py

示例3: loadFromXML

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import str2bool [as 别名]
    def loadFromXML(rootElement, namespace, version):

        # Then we verify its an IPC Message
        if rootElement.get("{http://www.w3.org/2001/XMLSchema-instance}type", "abstract") != "netzob-common:IRPMessage":
            raise NameError("The parsed xml doesn't represent a IRP message.")

        # Verifies the data field
        if rootElement.find("{" + namespace + "}data") == None or rootElement.find("{" + namespace + "}data").text == None or not rootElement.find("{" + namespace + "}data").text:
            raise NameError("The parsed message has no data specified")

        # Parse the data field and transform it into a byte array
        msg_data = bytearray(rootElement.find("{" + namespace + "}data").text)

        # Retrieve the id
        msg_id = rootElement.get("id")

        # Retrieve the timestamp
        msg_timestamp = int(rootElement.get("timestamp"))

        # Retrieves the direction
        msg_direction = rootElement.find("{" + namespace + "}direction").text

        # Retrieves the major
        msg_major = rootElement.find("{" + namespace + "}major").text

        # Retrieves the minor
        msg_minor = int(rootElement.find("{" + namespace + "}minor").text)

        # Retrieves the requestMode
        msg_requestMode = rootElement.find("{" + namespace + "}requestMode").text

        # Retrieves the pid
        msg_pid = int(rootElement.find("{" + namespace + "}pid").text)

        # Retrieves the status
        msg_status = int(rootElement.find("{" + namespace + "}status").text)

        # Retrieves the information
        msg_information = long(rootElement.find("{" + namespace + "}information").text)

        # Retrieves the cancel
        msg_cancel = TypeConvertor.str2bool(rootElement.find("{" + namespace + "}cancel").text)

        # Retrieves the sizeIn
        msg_sizeIn = int(rootElement.find("{" + namespace + "}sizeIn").text)

        # Retrieves the sizeOut
        msg_sizeOut = int(rootElement.find("{" + namespace + "}sizeOut").text)

        #Retrieve pattern

        pattern = []
        try:
            patTemp = rootElement.find("{" + namespace + "}pattern")
            pattern.append(patTemp.find("{" + namespace + "}direction").text)
            tokens = patTemp.findall("{" + namespace + "}token")
            #print "find "+str(tokens)
            tokenList = []
            for t in tokens:
                t_format = t.get("format")
                t_length = t.get("length")
                t_type = t.get("type")
                t_value = t.get("value").decode("base-64")
                tokenList.append(Token(t_format, t_length, t_type, t_value))
            pattern.append(tokenList)
        except:
            pattern = []

        #print "FACTORY "+rootElement.find("{" + namespace + "}pattern").text+" give "+str(pattern[0])+";"+str([str(i) for i in pattern[1]])
        # TODO : verify this ! Circular imports in python !
        # WARNING : verify this ! Circular imports in python !
        from netzob.Common.Models.IRPMessage import IRPMessage

        result = IRPMessage(msg_id, msg_timestamp, msg_data, "IRP", msg_direction, msg_major, msg_minor, msg_requestMode, msg_pid, msg_status, msg_information, msg_cancel, msg_sizeIn, msg_sizeOut, pattern)

        return result
开发者ID:KurSh,项目名称:netzob,代码行数:78,代码来源:IRPMessageFactory.py

示例4: loadProjectConfiguration

# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import str2bool [as 别名]
    def loadProjectConfiguration(xmlRoot, namespace, version):

        projectConfiguration = ProjectConfiguration()

        if version == "0.1":
            # Load the configuration of the vocabulary inference
            if xmlRoot.find("{" + namespace + "}vocabulary_inference") is not None:

                xmlVocabularyInference = xmlRoot.find("{" + namespace + "}vocabulary_inference")

                # Equivalence threshold
                xmlEquivalence = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_EQUIVALENCE_THRESHOLD)
                if xmlEquivalence is not None and xmlEquivalence.text is not None and len(xmlEquivalence.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_EQUIVALENCE_THRESHOLD, int(xmlEquivalence.text))

                # Orphan reduction
                xmlOrphanReduction = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_ORPHAN_REDUCTION)
                if xmlOrphanReduction is not None and xmlOrphanReduction.text is not None and len(xmlOrphanReduction.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_ORPHAN_REDUCTION, TypeConvertor.str2bool(xmlOrphanReduction.text))

                # Nb iteration
                xmlNbIteration = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_NB_ITERATION)
                if xmlNbIteration is not None and xmlNbIteration.text is not None and len(xmlNbIteration.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_NB_ITERATION, int(xmlNbIteration.text))

                # Do Internal Slick
                xmlDoInternalSlick = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DO_INTERNAL_SLICK)
                if xmlDoInternalSlick is not None and xmlDoInternalSlick.text is not None and len(xmlDoInternalSlick.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DO_INTERNAL_SLICK, TypeConvertor.str2bool(xmlDoInternalSlick.text))

                # Display Messages
                xmlDisplayMessages = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DISPLAY_MESSAGES)
                if xmlDisplayMessages is not None and xmlDisplayMessages.text is not None and len(xmlDisplayMessages.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DISPLAY_MESSAGES, TypeConvertor.str2bool(xmlDisplayMessages.text))

                # Display Symbol Structure
                xmlDisplaySymbolStructure = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DISPLAY_SYMBOL_STRUCTURE)
                if xmlDisplaySymbolStructure is not None and xmlDisplaySymbolStructure.text is not None and len(xmlDisplaySymbolStructure.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DISPLAY_SYMBOL_STRUCTURE, TypeConvertor.str2bool(xmlDisplaySymbolStructure.text))

                # Display Console
                xmlDisplayConsole = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DISPLAY_CONSOLE)
                if xmlDisplayConsole is not None and xmlDisplayConsole.text is not None and len(xmlDisplayConsole.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DISPLAY_CONSOLE, TypeConvertor.str2bool(xmlDisplayConsole.text))

                # Display Search
                xmlDisplaySearch = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DISPLAY_SEARCH)
                if xmlDisplaySearch is not None and xmlDisplaySearch.text is not None and len(xmlDisplaySearch.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DISPLAY_SEARCH, TypeConvertor.str2bool(xmlDisplaySearch.text))

                # Display Properties
                xmlDisplayProperties = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_DISPLAY_PROPERTIES)
                if xmlDisplayProperties is not None and xmlDisplayProperties.text is not None and len(xmlDisplayProperties.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_DISPLAY_PROPERTIES, TypeConvertor.str2bool(xmlDisplayProperties.text))

                # Global format
                xmlGlobalFormat = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_GLOBAL_FORMAT)
                if xmlGlobalFormat is not None and xmlGlobalFormat.text is not None and len(xmlGlobalFormat.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_GLOBAL_FORMAT, xmlGlobalFormat.text)

                # Global unitsize
                xmlGlobalUnitSize = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_GLOBAL_UNITSIZE)
                if xmlGlobalUnitSize is not None and xmlGlobalUnitSize.text is not None and len(xmlGlobalUnitSize.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_GLOBAL_UNITSIZE, xmlGlobalUnitSize.text)

                # Global sign
                xmlGlobalSign = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_GLOBAL_SIGN)
                if xmlGlobalSign is not None and xmlGlobalSign.text is not None and len(xmlGlobalSign.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_GLOBAL_SIGN, xmlGlobalSign.text)

                # Global endianess
                xmlGlobalEndianess = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_GLOBAL_ENDIANESS)
                if xmlGlobalEndianess is not None and xmlGlobalEndianess.text is not None and len(xmlGlobalEndianess.text) > 0:
                    projectConfiguration.setVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_GLOBAL_ENDIANESS, xmlGlobalEndianess.text)

                # Environmental dependencies
                xmlEnvDependencies = xmlVocabularyInference.find("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_ENVIRONMENTAL_DEPENDENCIES)
                if xmlEnvDependencies is not None:
                    envDependencies = projectConfiguration.getVocabularyInferenceParameter(ProjectConfiguration.VOCABULARY_ENVIRONMENTAL_DEPENDENCIES)
                    for xmlEnvDependency in xmlEnvDependencies.findall("{" + namespace + "}" + ProjectConfiguration.VOCABULARY_ENVIRONMENTAL_DEPENDENCY):
                        envDependencyName = xmlEnvDependency.get("name", "none")
                        envDependencyType = xmlEnvDependency.get("type", "none")
                        envDependencyValue = xmlEnvDependency.text
                        if envDependencyValue is None:
                            envDependencyValue = ""
                        envDependencies.append(EnvironmentalDependency(envDependencyName, envDependencyType, envDependencyValue))

            # Load the configuration of the grammar inference

            # Load the configuration of the simulation

        return projectConfiguration
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:94,代码来源:ProjectConfiguration.py


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