Simplify all other strings in main project class

This commit is contained in:
Veronica Berglyd Olsen
2022-04-16 17:00:08 +02:00
parent 72c5a9ee92
commit 2f547033cd
2 changed files with 20 additions and 14 deletions
+18 -12
View File
@@ -44,7 +44,7 @@ from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.common import ( from novelwriter.common import (
checkString, checkBool, checkInt, isHandle, formatTimeStamp, checkString, checkBool, checkInt, isHandle, formatTimeStamp,
makeFileNameSafe, hexToInt makeFileNameSafe, hexToInt, simplified
) )
from novelwriter.constants import nwLists, trConst, nwFiles, nwLabels from novelwriter.constants import nwLists, trConst, nwFiles, nwLabels
@@ -534,14 +534,16 @@ class NWProject():
if xItem.text is None: if xItem.text is None:
continue continue
if xItem.tag == "name": if xItem.tag == "name":
logger.verbose("Working Title: '%s'", xItem.text) self.projName = checkString(simplified(xItem.text), "")
self.projName = xItem.text logger.verbose("Working Title: '%s'", self.projName)
elif xItem.tag == "title": elif xItem.tag == "title":
logger.verbose("Title is '%s'", xItem.text) self.bookTitle = checkString(simplified(xItem.text), "")
self.bookTitle = xItem.text logger.verbose("Title is '%s'", self.bookTitle)
elif xItem.tag == "author": elif xItem.tag == "author":
logger.verbose("Author: '%s'", xItem.text) author = checkString(simplified(xItem.text), "")
self.bookAuthors.append(xItem.text) if author:
self.bookAuthors.append(author)
logger.verbose("Author: '%s'", author)
elif xItem.tag == "saveCount": elif xItem.tag == "saveCount":
self.saveCount = checkInt(xItem.text, 0) self.saveCount = checkInt(xItem.text, 0)
elif xItem.tag == "autoCount": elif xItem.tag == "autoCount":
@@ -956,14 +958,14 @@ class NWProject():
"""Set the project name (working title), This is the the title """Set the project name (working title), This is the the title
used for backup files etc. used for backup files etc.
""" """
self.projName = projName.strip() self.projName = simplified(projName)
self.setProjectChanged(True) self.setProjectChanged(True)
return True return True
def setBookTitle(self, bookTitle): def setBookTitle(self, bookTitle):
"""Set the book title, that is, the title to include in exports. """Set the book title, that is, the title to include in exports.
""" """
self.bookTitle = bookTitle.strip() self.bookTitle = simplified(bookTitle)
self.setProjectChanged(True) self.setProjectChanged(True)
return True return True
@@ -975,7 +977,7 @@ class NWProject():
self.bookAuthors = [] self.bookAuthors = []
for bookAuthor in bookAuthors.splitlines(): for bookAuthor in bookAuthors.splitlines():
bookAuthor = bookAuthor.strip() bookAuthor = simplified(bookAuthor)
if bookAuthor == "": if bookAuthor == "":
continue continue
self.bookAuthors.append(bookAuthor) self.bookAuthors.append(bookAuthor)
@@ -1114,7 +1116,9 @@ class NWProject():
def setAutoReplace(self, autoReplace): def setAutoReplace(self, autoReplace):
"""Update the auto-replace dictionary. """Update the auto-replace dictionary.
""" """
self.autoReplace = autoReplace self.autoReplace = {}
for key, entry in autoReplace.items():
self.autoReplace[key] = simplified(entry)
self.setProjectChanged(True) self.setProjectChanged(True)
return True return True
@@ -1123,7 +1127,9 @@ class NWProject():
""" """
for valKey, valEntry in titleFormat.items(): for valKey, valEntry in titleFormat.items():
if valKey in self.titleFormat: if valKey in self.titleFormat:
self.titleFormat[valKey] = checkString(valEntry, self.titleFormat[valKey]) self.titleFormat[valKey] = checkString(
simplified(valEntry), self.titleFormat[valKey]
)
return True return True
def setProjectChanged(self, bValue): def setProjectChanged(self, bValue):
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="1.7-alpha0" hexVersion="0x010700a0" fileVersion="1.4" timeStamp="2022-04-16 13:57:03"> <novelWriterXML appVersion="1.7-alpha0" hexVersion="0x010700a0" fileVersion="1.4" timeStamp="2022-04-16 16:54:15">
<project> <project>
<name>Project Name</name> <name>Project Name</name>
<title>Project Title</title> <title>Project Title</title>
@@ -23,7 +23,7 @@
<autoReplace> <autoReplace>
<entry key="A">B</entry> <entry key="A">B</entry>
<entry key="C">D</entry> <entry key="C">D</entry>
<entry key="This">With This Stuff </entry> <entry key="This">With This Stuff</entry>
</autoReplace> </autoReplace>
<titleFormat> <titleFormat>
<title>%title%</title> <title>%title%</title>