Exemplo n.º 1
0
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace("netzob", PROJECT_NAMESPACE)
    etree.register_namespace("netzob-common", COMMON_NAMESPACE)

    projectID = str(xmlProject.get("id"))
    projectName = xmlProject.get("name", "none")
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlProject.get("creation_date"))
    projectPath = xmlProject.get("path")
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    description = xmlProject.get("description")
    project.setDescription(description)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") is not None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"), PROJECT_NAMESPACE, "0.1"
        )
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") is not None:
        projectVocabulary = Vocabulary.loadVocabulary(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"),
            PROJECT_NAMESPACE,
            COMMON_NAMESPACE,
            "0.1",
            project,
        )
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") is not None:
        projectGrammar = Grammar.loadGrammar(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"), projectVocabulary, PROJECT_NAMESPACE, "0.1"
        )
        if projectGrammar is not None:
            project.setGrammar(projectGrammar)

    # Parse the simulator
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator") is not None:
        projectSimulator = Simulator.loadSimulator(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator"),
            PROJECT_NAMESPACE,
            "0.1",
            project.getGrammar().getAutomata(),
            project.getVocabulary(),
        )
        if projectSimulator is not None:
            project.setSimulator(projectSimulator)

    return project
Exemplo n.º 2
0
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace('netzob', PROJECT_NAMESPACE)
    etree.register_namespace('netzob-common', COMMON_NAMESPACE)

    projectID = xmlProject.get('id')
    projectName = xmlProject.get('name', 'none')
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlProject.get('creation_date'))
    projectPath = xmlProject.get('path')
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") != None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"), PROJECT_NAMESPACE, "0.1")
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") != None:
        projectVocabulary = Vocabulary.loadVocabulary(xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"), PROJECT_NAMESPACE, COMMON_NAMESPACE, "0.1", project)
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") != None:
        projectGrammar = Grammar.loadGrammar(xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"), projectVocabulary, PROJECT_NAMESPACE, "0.1")
        if projectGrammar != None:
            project.setGrammar(projectGrammar)

    return project
Exemplo n.º 3
0
 def __init__(self, id, name, creationDate, path):
     self.id = id
     self.name = name
     self.creationDate = creationDate
     self.path = path
     self.vocabulary = Vocabulary()
     self.grammar = Grammar()
     self.configuration = ProjectConfiguration.loadDefaultProjectConfiguration()
Exemplo n.º 4
0
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace('netzob', PROJECT_NAMESPACE)
    etree.register_namespace('netzob-common', COMMON_NAMESPACE)

    projectID = str(xmlProject.get('id'))
    projectName = xmlProject.get('name', 'none')
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(
        xmlProject.get('creation_date'))
    projectPath = xmlProject.get('path')
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    description = xmlProject.get('description')
    project.setDescription(description)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") is not None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"),
            PROJECT_NAMESPACE, "0.1")
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") is not None:
        projectVocabulary = Vocabulary.loadVocabulary(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"),
            PROJECT_NAMESPACE, COMMON_NAMESPACE, "0.1", project)
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") is not None:
        projectGrammar = Grammar.loadGrammar(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"),
            projectVocabulary, PROJECT_NAMESPACE, "0.1")
        if projectGrammar is not None:
            project.setGrammar(projectGrammar)

    # Parse the simulator
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator") is not None:
        projectSimulator = Simulator.loadSimulator(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator"),
            PROJECT_NAMESPACE, "0.1",
            project.getGrammar().getAutomata(), project.getVocabulary())
        if projectSimulator is not None:
            project.setSimulator(projectSimulator)

    return project
Exemplo n.º 5
0
 def __init__(self, id, name, creationDate, path):
     self.id = id
     self.name = name
     self.creationDate = creationDate
     self.path = path
     self.vocabulary = Vocabulary()
     self.grammar = Grammar()
     self.simulator = Simulator()
     self.configuration = ProjectConfiguration.loadDefaultProjectConfiguration(
     )
     self.description = None