Improved the export filter to exclude trash and orphan files always
This commit is contained in:
@@ -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
@@ -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
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
### Delete Me!
|
||||||
|
|
||||||
|
This scene is trash.
|
||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user