Exemplo n.º 1
0
    def populateImportList(self):

        def addFormat(name, icon, identifier):
            # Identifier serves to distingues 2 importers that would have the
            # same name.
            self.cmbImporters.addItem(QIcon.fromTheme(icon), name, identifier)

        def addHeader(name):
            self.cmbImporters.addItem(name, "header")
            self.cmbImporters.setItemData(self.cmbImporters.count() - 1, QBrush(QColor(style.highlightedTextDark)), Qt.ForegroundRole)
            self.cmbImporters.setItemData(self.cmbImporters.count() - 1, QBrush(QColor(style.highlightLight)), Qt.BackgroundRole)
            item = self.cmbImporters.model().item(self.cmbImporters.count() - 1)
            item.setFlags(Qt.ItemIsEnabled)

        lastEngine = ""

        for f in self.importers:
            # Header
            if f.engine != lastEngine:
                addHeader(f.engine)
                lastEngine = f.engine

            addFormat(f.name, f.icon, "{}:{}".format(f.engine, f.name))
            if not f.isValid():
                item = self.cmbImporters.model().item(self.cmbImporters.count() - 1)
                item.setFlags(Qt.NoItemFlags)

        if not pandocExporter().isValid():
            self.cmbImporters.addItem(
                self.style().standardIcon(QStyle.SP_MessageBoxWarning),
                "Install pandoc to import from much more formats",
                "::URL::http://pandoc.org/installing.html")

        self.cmbImporters.setCurrentIndex(1)
Exemplo n.º 2
0
    def startImport(self, filePath, parentItem, settingsWidget):

        formatTo = self.getSetting("formatTo").value().lower()
        wrap = self.getSetting("wrap").value().lower()

        # pandoc --from=markdown filename --to=opml --standalone
        args = [
            "--from={}".format(self.formatFrom),
            filePath,
            "--to={}".format(formatTo),
            "--wrap={}".format(wrap),
        ]

        if formatTo == "opml":
            args.append("--standalone")

        args += self.extraArgs

        r = pandocExporter().run(args)

        if formatTo == "opml":
            return self.opmlImporter.startImport("", parentItem,
                                            settingsWidget, fromString=r)
        elif formatTo == "markdown":
            return self.mdImporter.startImport(filePath, parentItem,
                                                settingsWidget, fromString=r)
Exemplo n.º 3
0
    def startImport(self, filePath, parentItem, settingsWidget):

        formatTo = self.getSetting("formatTo").value().lower()
        wrap = self.getSetting("wrap").value().lower()

        # pandoc --from=markdown filename --to=opml --standalone
        args = [
            "--from={}".format(self.formatFrom),
            filePath,
            "--to={}".format(formatTo),
            "--wrap={}".format(wrap),
        ]

        if formatTo == "opml":
            args.append("--standalone")

        args += self.extraArgs

        r = pandocExporter().run(args)

        if formatTo == "opml":
            return self.opmlImporter.startImport("",
                                                 parentItem,
                                                 settingsWidget,
                                                 fromString=r)
        elif formatTo == "markdown":
            return self.mdImporter.startImport(filePath,
                                               parentItem,
                                               settingsWidget,
                                               fromString=r)
Exemplo n.º 4
0
 def isValid(cls):
     return pandocExporter().isValid()
Exemplo n.º 5
0
 def isValid(cls):
     return pandocExporter().isValid()
Exemplo n.º 6
0
#!/usr/bin/env python
# --!-- coding: utf8 --!--

from manuskript.exporter.manuskript import manuskriptExporter
from manuskript.exporter.mmd import mmdExporter
from manuskript.exporter.pandoc import pandocExporter

exporters = [manuskriptExporter(), pandocExporter(), mmdExporter()]


def getExporterByName(name):
    for e in exporters:
        if e.name == name:
            return e

    return None
Exemplo n.º 7
0
#!/usr/bin/env python
# --!-- coding: utf8 --!--

from manuskript.exporter.manuskript import manuskriptExporter
from manuskript.exporter.pandoc import pandocExporter

exporters = [
    manuskriptExporter(),
    pandocExporter()
]

def getExporterByName(name):
    for e in exporters:
        if e.name == name:
            return e

    return None