def testImportExport(self):
        self.maxDiff = None

        # Import an XML file into a QTextDocument
        importer = XMLImporter('../SampleWiki', 'content.xml')
        doc = importer.importDocument()

        # export the document into XML
        exp = XMLExporter(None)
        actual = exp.getXmlString(doc)

        # Compare the exported XML document with the xml file from the disc
        with open("../SampleWiki/content.xml", 'r') as content_file:
            expected = content_file.read()
            self.assertEqual(actual, expected)
Пример #2
0
    def testImportExport(self):
        self.maxDiff = None

        # Import an XML file into a QTextDocument
        importer = XMLImporter('../SampleWiki', 'content.xml')
        doc = importer.importDocument()
        
        # export the document into XML
        exp = XMLExporter(None)
        actual = exp.getXmlString(doc)

        # Compare the exported XML document with the xml file from the disc
        with open("../SampleWiki/content.xml", 'r') as content_file:
            expected = content_file.read()
            self.assertEqual(actual, expected)
Пример #3
0
class XMLImporterController(AbstractFileImporterController):

    COLUMN_ID = 1
    COLUMN_SELECTED = 0

    def __init__(self, netzob, plugin):
        view = XMLImporterView(plugin, self)
        super(XMLImporterController, self).__init__(netzob, plugin, view)
        self.model = XMLImporter(netzob)

    def run(self):
        self.view.run()

    def doSetSourceFiles(self, filePathList):
        self.model.setSourceFiles(filePathList)

    def doReadMessages(self):
        self.model.readMessages()
        for message in self.model.messages:
            self.view.listListStore.append([False, str(message.getID()), str(message.getType()), message.getStringData()])

    def doGetMessageDetails(self, messageID):
        message = self.model.getMessageByID(str(messageID))

        properties = [(props.getName(), props.getCurrentValue()) for props in message.getProperties()
                      if props.getName() != 'Data']
        messageDetails = "\n".join(["{0}: {1}".format(*prop)
                                    for prop in properties])
        messageDetails += "\n\n" + TypeConvertor.hexdump(TypeConvertor.netzobRawToPythonRaw(message.getStringData()))
        return messageDetails

    def doImportMessages(self, selectedMessages):
        self.model.saveMessagesInCurrentProject(selectedMessages)
Пример #4
0
class XMLImporterController(AbstractFileImporterController):

    COLUMN_ID = 1
    COLUMN_SELECTED = 0

    def __init__(self, netzob, plugin):
        view = XMLImporterView(plugin, self)
        super(XMLImporterController, self).__init__(netzob, plugin, view)
        self.model = XMLImporter(netzob)

    def run(self):
        self.view.run()

    def doSetSourceFiles(self, filePathList):
        self.model.setSourceFiles(filePathList)

    def doReadMessages(self):
        self.model.readMessages()
        for message in self.model.messages:
            self.view.listListStore.append([
                False,
                str(message.getID()),
                str(message.getType()),
                message.getStringData()
            ])

    def doGetMessageDetails(self, messageID):
        message = self.model.getMessageByID(str(messageID))

        properties = [(props.getName(), props.getCurrentValue())
                      for props in message.getProperties()
                      if props.getName() != 'Data']
        messageDetails = "\n".join(
            ["{0}: {1}".format(*prop) for prop in properties])
        messageDetails += "\n\n" + TypeConvertor.hexdump(
            TypeConvertor.netzobRawToPythonRaw(message.getStringData()))
        return messageDetails

    def doImportMessages(self, selectedMessages):
        self.model.saveMessagesInCurrentProject(selectedMessages)
Пример #5
0
 def __init__(self, netzob, plugin):
     view = XMLImporterView(plugin, self)
     super(XMLImporterController, self).__init__(netzob, plugin, view)
     self.model = XMLImporter(netzob)
Пример #6
0
 def __init__(self, netzob, plugin):
     view = XMLImporterView(plugin, self)
     super(XMLImporterController, self).__init__(netzob, plugin, view)
     self.model = XMLImporter(netzob)