@@ -49,8 +49,8 @@ and the file extension ``.nwd``.
|
|||||||
|
|
||||||
If you wish to find the physical location of a file in the project, you can either look it up in the
|
If you wish to find the physical location of a file in the project, you can either look it up in the
|
||||||
project XML file, select :guilabel:`Show File Details` from the :guilabel:`Document` menu when
|
project XML file, select :guilabel:`Show File Details` from the :guilabel:`Document` menu when
|
||||||
having the document open, or look in one of the ``ToC`` files in the root of the project folder.
|
having the document open, or look in the ``ToC.txt`` file in the root of the project folder.
|
||||||
The ``ToC`` files have a list of all document files in the project and where they are saved.
|
The ``ToC.txt`` file has a list of all document files in the project and where they are saved.
|
||||||
|
|
||||||
The reason for this cryptic file naming is to avoid issues with file naming conventions and
|
The reason for this cryptic file naming is to avoid issues with file naming conventions and
|
||||||
restrictions on different operating systems, and also to have a file name that does not depend on
|
restrictions on different operating systems, and also to have a file name that does not depend on
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class nwFiles():
|
|||||||
PROJ_DICT = "wordlist.txt"
|
PROJ_DICT = "wordlist.txt"
|
||||||
PROJ_LOCK = "nwProject.lock"
|
PROJ_LOCK = "nwProject.lock"
|
||||||
TOC_TXT = "ToC.txt"
|
TOC_TXT = "ToC.txt"
|
||||||
TOC_JSON = "ToC.json"
|
|
||||||
SESS_STATS = "sessionStats.log"
|
SESS_STATS = "sessionStats.log"
|
||||||
INDEX_FILE = "tagsIndex.json"
|
INDEX_FILE = "tagsIndex.json"
|
||||||
OPTS_FILE = "guiOptions.json"
|
OPTS_FILE = "guiOptions.json"
|
||||||
|
|||||||
+2
-1
@@ -743,7 +743,7 @@ class NWProject():
|
|||||||
"""Close the current project and clear all meta data.
|
"""Close the current project and clear all meta data.
|
||||||
"""
|
"""
|
||||||
self.optState.saveSettings()
|
self.optState.saveSettings()
|
||||||
self.projTree.writeToCFiles()
|
self.projTree.writeToCFile()
|
||||||
self._appendSessionStats()
|
self._appendSessionStats()
|
||||||
self._clearLockFile()
|
self._clearLockFile()
|
||||||
self.clearProject()
|
self.clearProject()
|
||||||
@@ -1480,6 +1480,7 @@ class NWProject():
|
|||||||
os.path.join(self.projMeta, "timelineOptions.json"),
|
os.path.join(self.projMeta, "timelineOptions.json"),
|
||||||
os.path.join(self.projMeta, "docMergeOptions.json"),
|
os.path.join(self.projMeta, "docMergeOptions.json"),
|
||||||
os.path.join(self.projMeta, "sessionLogOptions.json"),
|
os.path.join(self.projMeta, "sessionLogOptions.json"),
|
||||||
|
os.path.join(self.projPath, "ToC.json"),
|
||||||
]
|
]
|
||||||
|
|
||||||
for rmFile in rmList:
|
for rmFile in rmList:
|
||||||
|
|||||||
+27
-32
@@ -26,7 +26,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
@@ -139,46 +138,42 @@ class NWTree():
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def writeToCFiles(self):
|
def writeToCFile(self):
|
||||||
"""Write the convenience table of contents files in the root of
|
"""Write the convenience table of contents file in the root of
|
||||||
the project directory. These files are there to assist the user
|
the project directory.
|
||||||
if they wish to browse the stored files.
|
|
||||||
"""
|
"""
|
||||||
tocText = os.path.join(self.theProject.projPath, nwFiles.TOC_TXT)
|
tocList = []
|
||||||
tocJson = os.path.join(self.theProject.projPath, nwFiles.TOC_JSON)
|
tocLen = 0
|
||||||
|
for tHandle in self._treeOrder:
|
||||||
|
tItem = self.__getitem__(tHandle)
|
||||||
|
if tItem is None:
|
||||||
|
continue
|
||||||
|
tFile = tHandle+".nwd"
|
||||||
|
if os.path.isfile(os.path.join(self.theProject.projContent, tFile)):
|
||||||
|
tocLine = "%-25s %-9s %-10s %s" % (
|
||||||
|
os.path.join("content", tFile),
|
||||||
|
tItem.itemClass.name,
|
||||||
|
tItem.itemLayout.name,
|
||||||
|
tItem.itemName,
|
||||||
|
)
|
||||||
|
tocList.append(tocLine)
|
||||||
|
tocLen = max(tocLen, len(tocLine))
|
||||||
|
|
||||||
jsonData = []
|
|
||||||
try:
|
try:
|
||||||
# Dump the text
|
# Dump the text
|
||||||
|
tocText = os.path.join(self.theProject.projPath, nwFiles.TOC_TXT)
|
||||||
with open(tocText, mode="w", encoding="utf8") as outFile:
|
with open(tocText, mode="w", encoding="utf8") as outFile:
|
||||||
outFile.write("\n")
|
outFile.write("\n")
|
||||||
outFile.write(" Table of Contents\n")
|
outFile.write("Table of Contents\n")
|
||||||
outFile.write("===================\n")
|
outFile.write("=================\n")
|
||||||
outFile.write("\n")
|
outFile.write("\n")
|
||||||
outFile.write(" %-25s %-9s %s\n" % ("File Name", "Class", "Document Label"))
|
outFile.write("%-25s %-9s %-10s %s\n" % (
|
||||||
outFile.write("-"*80+"\n")
|
"File Name", "Class", "Layout", "Document Label"
|
||||||
for tHandle in sorted(self._treeOrder):
|
))
|
||||||
tItem = self.__getitem__(tHandle)
|
outFile.write("-"*tocLen + "\n")
|
||||||
if tItem is None:
|
outFile.write("\n".join(tocList))
|
||||||
continue
|
|
||||||
tFile = tHandle+".nwd"
|
|
||||||
if os.path.isfile(os.path.join(self.theProject.projContent, tFile)):
|
|
||||||
outFile.write(" %-25s %-9s %s\n" % (
|
|
||||||
os.path.join("content", tFile),
|
|
||||||
tItem.itemClass.name,
|
|
||||||
tItem.itemName,
|
|
||||||
))
|
|
||||||
jsonData.append([
|
|
||||||
os.path.join("content", tFile),
|
|
||||||
tItem.itemClass.name,
|
|
||||||
tItem.itemName,
|
|
||||||
])
|
|
||||||
outFile.write("\n")
|
outFile.write("\n")
|
||||||
|
|
||||||
# Dump the JSON
|
|
||||||
with open(tocJson, mode="w+", encoding="utf8") as outFile:
|
|
||||||
json.dump(jsonData, outFile, indent=2)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
|
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
[
|
|
||||||
[
|
|
||||||
"content/14298de4d9524.nwd",
|
|
||||||
"CHARACTER",
|
|
||||||
"John Smith"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/53b69b83cdafc.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Title Page"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/5eaea4e8cdee8.nwd",
|
|
||||||
"WORLD",
|
|
||||||
"Mars"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/636b6aa9b697b.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Making a Scene"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/6a2d6d5f4f401.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Chapter One"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/88706ddc78b1b.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Chapter Two"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/8a5deb88c0e97.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Old File"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/96b68994dfa3d.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"A Note on Structure"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/974e400180a99.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Page"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/ae7339df26ded.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"We Found John!"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/b3e74dbc1f584.nwd",
|
|
||||||
"WORLD",
|
|
||||||
"Earth"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/b8136a5a774a0.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Delete Me!"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/ba8a28a246524.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Interlude"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/bb2c23b3c42cc.nwd",
|
|
||||||
"CHARACTER",
|
|
||||||
"Jane Smith"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/bc0cbd2a407f3.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Another Scene"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/edca4be2fcaf8.nwd",
|
|
||||||
"NOVEL",
|
|
||||||
"Part One"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"content/f1471bef9f2ae.nwd",
|
|
||||||
"WORLD",
|
|
||||||
"Space"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
+21
-22
@@ -1,24 +1,23 @@
|
|||||||
|
|
||||||
Table of Contents
|
Table of Contents
|
||||||
===================
|
=================
|
||||||
|
|
||||||
File Name Class Document Label
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
content/14298de4d9524.nwd CHARACTER John Smith
|
|
||||||
content/53b69b83cdafc.nwd NOVEL Title Page
|
|
||||||
content/5eaea4e8cdee8.nwd WORLD Mars
|
|
||||||
content/636b6aa9b697b.nwd NOVEL Making a Scene
|
|
||||||
content/6a2d6d5f4f401.nwd NOVEL Chapter One
|
|
||||||
content/88706ddc78b1b.nwd NOVEL Chapter Two
|
|
||||||
content/8a5deb88c0e97.nwd NOVEL Old File
|
|
||||||
content/96b68994dfa3d.nwd NOVEL A Note on Structure
|
|
||||||
content/974e400180a99.nwd NOVEL Page
|
|
||||||
content/ae7339df26ded.nwd NOVEL We Found John!
|
|
||||||
content/b3e74dbc1f584.nwd WORLD Earth
|
|
||||||
content/b8136a5a774a0.nwd NOVEL Delete Me!
|
|
||||||
content/ba8a28a246524.nwd NOVEL Interlude
|
|
||||||
content/bb2c23b3c42cc.nwd CHARACTER Jane Smith
|
|
||||||
content/bc0cbd2a407f3.nwd NOVEL Another Scene
|
|
||||||
content/edca4be2fcaf8.nwd NOVEL Part One
|
|
||||||
content/f1471bef9f2ae.nwd WORLD Space
|
|
||||||
|
|
||||||
|
File Name Class Layout Document Label
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
content/53b69b83cdafc.nwd NOVEL TITLE Title Page
|
||||||
|
content/974e400180a99.nwd NOVEL PAGE Page
|
||||||
|
content/edca4be2fcaf8.nwd NOVEL PARTITION Part One
|
||||||
|
content/6a2d6d5f4f401.nwd NOVEL CHAPTER Chapter One
|
||||||
|
content/636b6aa9b697b.nwd NOVEL SCENE Making a Scene
|
||||||
|
content/bc0cbd2a407f3.nwd NOVEL SCENE Another Scene
|
||||||
|
content/ba8a28a246524.nwd NOVEL UNNUMBERED Interlude
|
||||||
|
content/96b68994dfa3d.nwd NOVEL NOTE A Note on Structure
|
||||||
|
content/88706ddc78b1b.nwd NOVEL CHAPTER Chapter Two
|
||||||
|
content/ae7339df26ded.nwd NOVEL SCENE We Found John!
|
||||||
|
content/14298de4d9524.nwd CHARACTER NOTE John Smith
|
||||||
|
content/bb2c23b3c42cc.nwd CHARACTER NOTE Jane Smith
|
||||||
|
content/b3e74dbc1f584.nwd WORLD NOTE Earth
|
||||||
|
content/f1471bef9f2ae.nwd WORLD NOTE Space
|
||||||
|
content/5eaea4e8cdee8.nwd WORLD NOTE Mars
|
||||||
|
content/8a5deb88c0e97.nwd NOVEL SCENE Old File
|
||||||
|
content/b8136a5a774a0.nwd NOVEL SCENE Delete Me!
|
||||||
|
|||||||
@@ -627,7 +627,6 @@ def testProjectOldFormat(nwDummy, nwOldProj):
|
|||||||
# Check that new files have been created
|
# Check that new files have been created
|
||||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "guiOptions.json"))
|
assert os.path.isfile(os.path.join(nwOldProj, "meta", "guiOptions.json"))
|
||||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "sessionStats.log"))
|
assert os.path.isfile(os.path.join(nwOldProj, "meta", "sessionStats.log"))
|
||||||
assert os.path.isfile(os.path.join(nwOldProj, "ToC.json"))
|
|
||||||
assert os.path.isfile(os.path.join(nwOldProj, "ToC.txt"))
|
assert os.path.isfile(os.path.join(nwOldProj, "ToC.txt"))
|
||||||
|
|
||||||
@pytest.mark.project
|
@pytest.mark.project
|
||||||
|
|||||||
Reference in New Issue
Block a user