Merge pull request #104 from vkbo/bugfixes

Export Fixes
This commit is contained in:
Veronica K. Berglyd Olsen
2019-10-31 11:40:11 +01:00
committed by GitHub
5 changed files with 52 additions and 29 deletions
+1 -10
View File
@@ -35,16 +35,7 @@ class ConcatFile(TextFile):
logger.verbose("Parsing content of item '%s'" % tHandle) logger.verbose("Parsing content of item '%s'" % tHandle)
theItem = self.theProject.getItem(tHandle) if not self.checkInclude(tHandle):
isNone = theItem.itemLayout == nwItemLayout.NO_LAYOUT
isNote = theItem.itemLayout == nwItemLayout.NOTE
isNovel = not isNone and not isNote
if isNone:
return False
if isNote and not self.expNotes:
return False
if isNovel and not self.expNovel:
return False return False
self.theConv.setText(tHandle) self.theConv.setText(tHandle)
+30 -12
View File
@@ -17,7 +17,7 @@ from os import path
from PyQt5.QtWidgets import QMessageBox from PyQt5.QtWidgets import QMessageBox
from nw.convert.text.totext import ToText from nw.convert.text.totext import ToText
from nw.enum import nwAlert, nwItemLayout from nw.enum import nwAlert, nwItemType, nwItemLayout, nwItemClass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -120,17 +120,8 @@ class TextFile():
def addText(self, tHandle): def addText(self, tHandle):
logger.verbose("Parsing content of item '%s'" % tHandle) logger.verbose("Parsing content of item '%s'" % tHandle)
theItem = self.theProject.getItem(tHandle) if not self.checkInclude(tHandle):
isNone = theItem.itemLayout == nwItemLayout.NO_LAYOUT
isNote = theItem.itemLayout == nwItemLayout.NOTE
isNovel = not isNone and not isNote
if isNone:
return False
if isNote and not self.expNotes:
return False
if isNovel and not self.expNovel:
return False return False
self.theConv.setText(tHandle) self.theConv.setText(tHandle)
@@ -145,6 +136,33 @@ class TextFile():
return True return True
def checkInclude(self, tHandle):
"""This function checks whether a file should be included in the export or not. For standard
note and novel files, this is controlled by the options selected by the user. For other
files classified as non-exportable, a few checks must be made, and the following are not:
* Items that are not actual files.
* Items that have been orphaned which are tagged as NO_LAYOUT and NO_CLASS.
* Items that appear in the TRASH folder
"""
theItem = self.theProject.getItem(tHandle)
isNone = theItem.itemType != nwItemType.FILE
isNone |= theItem.itemLayout == nwItemLayout.NO_LAYOUT
isNone |= theItem.itemClass == nwItemClass.NO_CLASS
isNone |= theItem.itemClass == nwItemClass.TRASH
isNone |= theItem.parHandle == self.theProject.trashRoot
isNote = theItem.itemLayout == nwItemLayout.NOTE
isNovel = not isNone and not isNote
if isNone:
return False
if isNote and not self.expNotes:
return False
if isNovel and not self.expNovel:
return False
return True
## ##
# Internal Functions # Internal Functions
## ##
+2 -3
View File
@@ -213,7 +213,7 @@ class GuiExport(QDialog):
# If we've reached this point, we're also running Pandoc # If we've reached this point, we're also running Pandoc
if self._callPandoc(tFormat, pFormat): if self._callPandoc(saveTo, tFormat, pFormat):
self.exportProgress.setValue(nItems) self.exportProgress.setValue(nItems)
self.exportStatus.setText("Pandoc conversion complete") self.exportStatus.setText("Pandoc conversion complete")
logger.verbose("Pandoc conversion complete") logger.verbose("Pandoc conversion complete")
@@ -225,7 +225,7 @@ class GuiExport(QDialog):
return True return True
def _callPandoc(self, inFmt, outFmt): def _callPandoc(self, inFile, inFmt, outFmt):
pFmt = { pFmt = {
GuiExportPandoc.FMT_ODT : "odt", GuiExportPandoc.FMT_ODT : "odt",
@@ -246,7 +246,6 @@ class GuiExport(QDialog):
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
inFile = self.tabMain.exportPath.text()
outFile = path.splitext(inFile)[0]+GuiExportPandoc.FMT_EXT[outFmt] outFile = path.splitext(inFile)[0]+GuiExportPandoc.FMT_EXT[outFmt]
fileName = path.basename(outFile) fileName = path.basename(outFile)
@@ -0,0 +1,3 @@
### Delete Me!
This scene is trash.
+16 -4
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-10-29 19:06:30"> <novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-10-31 11:33:41">
<project> <project>
<name>Sample Project</name> <name>Sample Project</name>
<title>Sample Project</title> <title>Sample Project</title>
@@ -9,9 +9,9 @@
</project> </project>
<settings> <settings>
<spellCheck>True</spellCheck> <spellCheck>True</spellCheck>
<lastEdited>636b6aa9b697b</lastEdited> <lastEdited>b8136a5a774a0</lastEdited>
<lastViewed>ba8a28a246524</lastViewed> <lastViewed>ba8a28a246524</lastViewed>
<lastWordCount>873</lastWordCount> <lastWordCount>879</lastWordCount>
<autoReplace> <autoReplace>
<A>B</A> <A>B</A>
<B>E</B> <B>E</B>
@@ -33,7 +33,7 @@
<entry blue="175" green="0" red="117">Main</entry> <entry blue="175" green="0" red="117">Main</entry>
</importance> </importance>
</settings> </settings>
<content count="19"> <content count="20">
<item handle="7031beac91f75" order="0" parent="None"> <item handle="7031beac91f75" order="0" parent="None">
<name>Novel</name> <name>Novel</name>
<type>ROOT</type> <type>ROOT</type>
@@ -232,5 +232,17 @@
<paraCount>0</paraCount> <paraCount>0</paraCount>
<cursorPos>1</cursorPos> <cursorPos>1</cursorPos>
</item> </item>
<item handle="b8136a5a774a0" order="1" parent="98acd8c76c93a">
<name>Delete Me!</name>
<type>FILE</type>
<class>NOVEL</class>
<status>New</status>
<expanded>False</expanded>
<layout>SCENE</layout>
<charCount>30</charCount>
<wordCount>6</wordCount>
<paraCount>1</paraCount>
<cursorPos>36</cursorPos>
</item>
</content> </content>
</novelWriterXML> </novelWriterXML>