Logger messages (#818)
* Change the way logger messages are generated by using the printf-like method * Use single quotes around log values that can be empty strings * Fix bug in log message
This commit is contained in:
committed by
GitHub
parent
671888b6ea
commit
1b89d0a4f0
+1
-3
@@ -209,9 +209,7 @@ def main(sysArgs=None):
|
||||
pkgLogger.addHandler(cHandle)
|
||||
pkgLogger.setLevel(logLevel)
|
||||
|
||||
logger.info("Starting novelWriter %s (%s) %s" % (
|
||||
__version__, __hexversion__, __date__
|
||||
))
|
||||
logger.info("Starting novelWriter %s (%s) %s", __version__, __hexversion__, __date__)
|
||||
|
||||
# Check Packages and Versions
|
||||
errorData = []
|
||||
|
||||
+11
-11
@@ -272,7 +272,7 @@ class Config:
|
||||
confRoot = QStandardPaths.writableLocation(QStandardPaths.ConfigLocation)
|
||||
self.confPath = os.path.join(os.path.abspath(confRoot), self.appHandle)
|
||||
else:
|
||||
logger.info("Setting config from alternative path: %s" % confPath)
|
||||
logger.info("Setting config from alternative path: %s", confPath)
|
||||
self.confPath = confPath
|
||||
|
||||
if dataPath is None:
|
||||
@@ -282,11 +282,11 @@ class Config:
|
||||
dataRoot = QStandardPaths.writableLocation(QStandardPaths.DataLocation)
|
||||
self.dataPath = os.path.join(os.path.abspath(dataRoot), self.appHandle)
|
||||
else:
|
||||
logger.info("Setting data path from alternative path: %s" % dataPath)
|
||||
logger.info("Setting data path from alternative path: %s", dataPath)
|
||||
self.dataPath = dataPath
|
||||
|
||||
logger.verbose("Config path: %s" % self.confPath)
|
||||
logger.verbose("Data path: %s" % self.dataPath)
|
||||
logger.verbose("Config path: %s", self.confPath)
|
||||
logger.verbose("Data path: %s", self.dataPath)
|
||||
|
||||
self.confFile = self.appHandle+".conf"
|
||||
self.lastPath = os.path.expanduser("~")
|
||||
@@ -310,8 +310,8 @@ class Config:
|
||||
# Internationalisation
|
||||
self.nwLangPath = os.path.join(self.assetPath, "i18n")
|
||||
|
||||
logger.verbose("App path: %s" % self.appPath)
|
||||
logger.verbose("Last path: %s" % self.lastPath)
|
||||
logger.verbose("App path: %s", self.appPath)
|
||||
logger.verbose("Last path: %s", self.lastPath)
|
||||
|
||||
# If config folder does not exist, create it.
|
||||
# This assumes that the os config folder itself exists.
|
||||
@@ -319,7 +319,7 @@ class Config:
|
||||
try:
|
||||
os.mkdir(self.confPath)
|
||||
except Exception as e:
|
||||
logger.error("Could not create folder: %s" % self.confPath)
|
||||
logger.error("Could not create folder: %s", self.confPath)
|
||||
logException()
|
||||
self.hasError = True
|
||||
self.errData.append("Could not create folder: %s" % self.confPath)
|
||||
@@ -342,7 +342,7 @@ class Config:
|
||||
try:
|
||||
os.mkdir(self.dataPath)
|
||||
except Exception as e:
|
||||
logger.error("Could not create folder: %s" % self.dataPath)
|
||||
logger.error("Could not create folder: %s", self.dataPath)
|
||||
logException()
|
||||
self.hasError = True
|
||||
self.errData.append("Could not create folder: %s" % self.dataPath)
|
||||
@@ -392,7 +392,7 @@ class Config:
|
||||
lngFile = "%s_%s" % (lngBase, lngCode.replace("-", "_"))
|
||||
if lngFile not in self.qtTrans:
|
||||
if qTrans.load(lngFile, lngPath):
|
||||
logger.debug("Loaded: %s" % os.path.join(lngPath, lngFile))
|
||||
logger.debug("Loaded: %s", os.path.join(lngPath, lngFile))
|
||||
nwApp.installTranslator(qTrans)
|
||||
self.qtTrans[lngFile] = qTrans
|
||||
|
||||
@@ -898,10 +898,10 @@ class Config:
|
||||
"""
|
||||
if thePath in self.recentProj:
|
||||
del self.recentProj[thePath]
|
||||
logger.verbose("Removed recent: %s" % thePath)
|
||||
logger.verbose("Removed recent: %s", thePath)
|
||||
self.saveRecentCache()
|
||||
else:
|
||||
logger.error("Unknown recent: %s" % thePath)
|
||||
logger.error("Unknown recent: %s", thePath)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@ class NWDoc():
|
||||
return None
|
||||
|
||||
docFile = self._docHandle+".nwd"
|
||||
logger.debug("Opening document %s" % docFile)
|
||||
logger.debug("Opening document: %s", docFile)
|
||||
|
||||
docPath = os.path.join(self.theProject.projContent, docFile)
|
||||
self._fileLoc = docPath
|
||||
@@ -120,7 +120,7 @@ class NWDoc():
|
||||
self.theProject.ensureFolderStructure()
|
||||
|
||||
docFile = self._docHandle+".nwd"
|
||||
logger.debug("Saving document %s" % docFile)
|
||||
logger.debug("Saving document: %s", docFile)
|
||||
|
||||
docPath = os.path.join(self.theProject.projContent, docFile)
|
||||
docTemp = os.path.join(self.theProject.projContent, docFile+"~")
|
||||
@@ -170,7 +170,7 @@ class NWDoc():
|
||||
if os.path.isfile(chkFile):
|
||||
try:
|
||||
os.unlink(chkFile)
|
||||
logger.debug("Deleted: %s" % chkFile)
|
||||
logger.debug("Deleted: %s", chkFile)
|
||||
except Exception as e:
|
||||
self._docError = str(e)
|
||||
return False
|
||||
@@ -237,7 +237,7 @@ class NWDoc():
|
||||
self._docMeta["layout"] = nwItemLayout[metaBits[1]]
|
||||
|
||||
else:
|
||||
logger.debug("Ignoring meta data: '%s'" % metaLine.strip())
|
||||
logger.debug("Ignoring meta data: '%s'", metaLine.strip())
|
||||
|
||||
return
|
||||
|
||||
|
||||
+12
-12
@@ -85,7 +85,7 @@ class NWIndex():
|
||||
def deleteHandle(self, tHandle):
|
||||
"""Delete all entries of a given document handle.
|
||||
"""
|
||||
logger.debug("Removing item %s from the index" % tHandle)
|
||||
logger.debug("Removing item '%s' from the index", tHandle)
|
||||
|
||||
delTags = []
|
||||
for tTag in self._tagIndex:
|
||||
@@ -107,7 +107,7 @@ class NWIndex():
|
||||
moved from the archive or trash folders back into the active
|
||||
project.
|
||||
"""
|
||||
logger.debug("Re-indexing item %s" % tHandle)
|
||||
logger.debug("Re-indexing item '%s'", tHandle)
|
||||
|
||||
tItem = self.theProject.projTree[tHandle]
|
||||
if tItem is None:
|
||||
@@ -217,7 +217,7 @@ class NWIndex():
|
||||
self.indexBroken = True
|
||||
|
||||
tEnd = time()
|
||||
logger.debug("Index check took %.3f ms" % ((tEnd - tStart)*1000))
|
||||
logger.debug("Index check took %.3f ms", (tEnd - tStart)*1000)
|
||||
logger.debug("Index check complete")
|
||||
|
||||
if self.indexBroken:
|
||||
@@ -239,16 +239,16 @@ class NWIndex():
|
||||
theRoot = self.theProject.projTree.getRootItem(tHandle)
|
||||
|
||||
if theItem is None:
|
||||
logger.info("Not indexing unknown item %s" % tHandle)
|
||||
logger.info("Not indexing unknown item '%s'", tHandle)
|
||||
return False
|
||||
if theItem.itemType != nwItemType.FILE:
|
||||
logger.info("Not indexing non-file item %s" % tHandle)
|
||||
logger.info("Not indexing non-file item '%s'", tHandle)
|
||||
return False
|
||||
if theItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||
logger.info("Not indexing no-layout item %s" % tHandle)
|
||||
logger.info("Not indexing no-layout item '%s'", tHandle)
|
||||
return False
|
||||
if theItem.itemParent is None:
|
||||
logger.info("Not indexing orphaned item %s" % tHandle)
|
||||
logger.info("Not indexing orphaned item '%s'", tHandle)
|
||||
return False
|
||||
|
||||
# Run word counter for the whole text
|
||||
@@ -257,16 +257,16 @@ class NWIndex():
|
||||
|
||||
# If the file is archived or trashed, we don't index the file itself
|
||||
if self.theProject.projTree.isTrashRoot(theItem.itemParent):
|
||||
logger.info("Not indexing trash item %s" % tHandle)
|
||||
logger.info("Not indexing trash item '%s'", tHandle)
|
||||
return False
|
||||
if theRoot.itemClass == nwItemClass.ARCHIVE:
|
||||
logger.info("Not indexing archived item %s" % tHandle)
|
||||
logger.info("Not indexing archived item '%s'", tHandle)
|
||||
return False
|
||||
|
||||
itemClass = theItem.itemClass
|
||||
itemLayout = theItem.itemLayout
|
||||
|
||||
logger.debug("Indexing item with handle %s" % tHandle)
|
||||
logger.debug("Indexing item with handle '%s'", tHandle)
|
||||
|
||||
# Check file type, and reset its old index
|
||||
# Also add a default entry T000000 in case the file has no title
|
||||
@@ -457,11 +457,11 @@ class NWIndex():
|
||||
"""
|
||||
isValid, theBits, _ = self.scanThis(aLine)
|
||||
if not isValid or len(theBits) < 2:
|
||||
logger.warning("Skipping keyword with %d value(s) in %s" % (len(theBits), tHandle))
|
||||
logger.warning("Skipping keyword with %d value(s) in '%s'", len(theBits), tHandle)
|
||||
return
|
||||
|
||||
if theBits[0] not in nwKeyWords.VALID_KEYS:
|
||||
logger.warning("Skipping invalid keyword '%s' in %s" % (theBits[0], tHandle))
|
||||
logger.warning("Skipping invalid keyword '%s' in '%s'", theBits[0], tHandle)
|
||||
return
|
||||
|
||||
sTitle = "T%06d" % nTitle
|
||||
|
||||
+4
-4
@@ -133,7 +133,7 @@ class NWItem():
|
||||
# Sliently skip as we may otherwise cause orphaned
|
||||
# items if an otherwise valid file is opened by a
|
||||
# version of novelWriter that doesn't know the tag.
|
||||
logger.error("Unknown tag '%s'" % xValue.tag)
|
||||
logger.error("Unknown tag '%s'", xValue.tag)
|
||||
|
||||
return True
|
||||
|
||||
@@ -205,7 +205,7 @@ class NWItem():
|
||||
elif isItemType(theType):
|
||||
self.itemType = nwItemType[theType]
|
||||
else:
|
||||
logger.error("Unrecognised item type '%s'" % theType)
|
||||
logger.error("Unrecognised item type '%s'", theType)
|
||||
self.itemType = nwItemType.NO_TYPE
|
||||
return
|
||||
|
||||
@@ -218,7 +218,7 @@ class NWItem():
|
||||
elif isItemClass(theClass):
|
||||
self.itemClass = nwItemClass[theClass]
|
||||
else:
|
||||
logger.error("Unrecognised item class '%s'" % theClass)
|
||||
logger.error("Unrecognised item class '%s'", theClass)
|
||||
self.itemClass = nwItemClass.NO_CLASS
|
||||
return
|
||||
|
||||
@@ -231,7 +231,7 @@ class NWItem():
|
||||
elif isItemLayout(theLayout):
|
||||
self.itemLayout = nwItemLayout[theLayout]
|
||||
else:
|
||||
logger.error("Unrecognised item layout '%s'" % theLayout)
|
||||
logger.error("Unrecognised item layout '%s'", theLayout)
|
||||
self.itemLayout = nwItemLayout.NO_LAYOUT
|
||||
return
|
||||
|
||||
|
||||
+2
-2
@@ -174,11 +174,11 @@ class OptionState():
|
||||
"""Saves a value, with a given group and name.
|
||||
"""
|
||||
if setGroup not in self.validMap:
|
||||
logger.error("Unknown option group '%s'" % setGroup)
|
||||
logger.error("Unknown option group '%s'", setGroup)
|
||||
return False
|
||||
|
||||
if setName not in self.validMap[setGroup]:
|
||||
logger.error("Unknown option name '%s'" % setName)
|
||||
logger.error("Unknown option name '%s'", setName)
|
||||
return False
|
||||
|
||||
if setGroup not in self.theState:
|
||||
|
||||
+33
-33
@@ -369,7 +369,7 @@ class NWProject():
|
||||
|
||||
self.clearProject()
|
||||
self.projPath = os.path.abspath(os.path.dirname(fileName))
|
||||
logger.debug("Opening project: %s" % self.projPath)
|
||||
logger.debug("Opening project: %s", self.projPath)
|
||||
|
||||
# Standard Folders and Files
|
||||
# ==========================
|
||||
@@ -385,7 +385,7 @@ class NWProject():
|
||||
|
||||
legacyList = [] # Cleanup is done later
|
||||
for projItem in os.listdir(self.projPath):
|
||||
logger.verbose("Project contains: %s" % projItem)
|
||||
logger.verbose("Project contains: %s", projItem)
|
||||
if projItem.startswith("data_"):
|
||||
legacyList.append(projItem)
|
||||
|
||||
@@ -442,8 +442,8 @@ class NWProject():
|
||||
hexVersion = xRoot.attrib.get("hexVersion", "0x0")
|
||||
fileVersion = xRoot.attrib.get("fileVersion", self.tr("Unknown"))
|
||||
|
||||
logger.verbose("XML root is %s" % nwxRoot)
|
||||
logger.verbose("File version is %s" % fileVersion)
|
||||
logger.verbose("XML root is '%s'", nwxRoot)
|
||||
logger.verbose("File version is '%s'", fileVersion)
|
||||
|
||||
# Check File Type
|
||||
# ===============
|
||||
@@ -503,13 +503,13 @@ class NWProject():
|
||||
if xItem.text is None:
|
||||
continue
|
||||
if xItem.tag == "name":
|
||||
logger.verbose("Working Title: '%s'" % xItem.text)
|
||||
logger.verbose("Working Title: '%s'", xItem.text)
|
||||
self.projName = xItem.text
|
||||
elif xItem.tag == "title":
|
||||
logger.verbose("Title is '%s'" % xItem.text)
|
||||
logger.verbose("Title is '%s'", xItem.text)
|
||||
self.bookTitle = xItem.text
|
||||
elif xItem.tag == "author":
|
||||
logger.verbose("Author: '%s'" % xItem.text)
|
||||
logger.verbose("Author: '%s'", xItem.text)
|
||||
self.bookAuthors.append(xItem.text)
|
||||
elif xItem.tag == "saveCount":
|
||||
self.saveCount = checkInt(xItem.text, 0)
|
||||
@@ -610,7 +610,7 @@ class NWProject():
|
||||
if not self.ensureFolderStructure():
|
||||
return False
|
||||
|
||||
logger.debug("Saving project: %s" % self.projPath)
|
||||
logger.debug("Saving project: %s", self.projPath)
|
||||
|
||||
if autoSave:
|
||||
self.autoCount += 1
|
||||
@@ -783,7 +783,7 @@ class NWProject():
|
||||
if not os.path.isdir(baseDir):
|
||||
try:
|
||||
os.mkdir(baseDir)
|
||||
logger.debug("Created folder %s" % baseDir)
|
||||
logger.debug("Created folder: %s", baseDir)
|
||||
except Exception as e:
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Could not create backup folder."), str(e)
|
||||
@@ -805,7 +805,7 @@ class NWProject():
|
||||
self._clearLockFile()
|
||||
shutil.make_archive(baseName, "zip", self.projPath, ".")
|
||||
self._writeLockFile()
|
||||
logger.info("Backup written to: %s" % archName)
|
||||
logger.info("Backup written to: %s", archName)
|
||||
if doNotify:
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Backup archive file written to: {0}"
|
||||
@@ -904,7 +904,7 @@ class NWProject():
|
||||
if not os.path.isdir(projPath):
|
||||
try:
|
||||
os.mkdir(projPath)
|
||||
logger.debug("Created folder %s" % projPath)
|
||||
logger.debug("Created folder: %s", projPath)
|
||||
except Exception as e:
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Could not create new project folder."), str(e)
|
||||
@@ -1162,12 +1162,12 @@ class NWProject():
|
||||
# Item's parent exists, but hasn't been sent yet, so add
|
||||
# it again to the end, but make sure this doesn't get
|
||||
# out hand, so we cap at 10000 items
|
||||
logger.warning("Item %s found before its parent" % tHandle)
|
||||
logger.warning("Item '%s' found before its parent", tHandle)
|
||||
iterItems.append(tHandle)
|
||||
nMax = min(len(iterItems), 10000)
|
||||
else:
|
||||
# Item is orphaned
|
||||
logger.error("Item %s has no parent in current tree" % tHandle)
|
||||
logger.error("Item '%s' has no parent in current tree", tHandle)
|
||||
tItem.setParent(None)
|
||||
yield tItem
|
||||
|
||||
@@ -1221,7 +1221,7 @@ class NWProject():
|
||||
try:
|
||||
with open(loadFile, mode="r", encoding="utf8") as inFile:
|
||||
self.langData = json.load(inFile)
|
||||
logger.debug("Loaded project language file: %s" % os.path.basename(loadFile))
|
||||
logger.debug("Loaded project language file: %s", os.path.basename(loadFile))
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to project language file")
|
||||
@@ -1299,7 +1299,7 @@ class NWProject():
|
||||
if not os.path.isdir(thePath):
|
||||
try:
|
||||
os.mkdir(thePath)
|
||||
logger.debug("Created folder %s" % thePath)
|
||||
logger.debug("Created folder: %s", thePath)
|
||||
except Exception as e:
|
||||
self.makeAlert([
|
||||
self.tr("Could not create folder."), str(e)
|
||||
@@ -1343,19 +1343,19 @@ class NWProject():
|
||||
orphanFiles = []
|
||||
for fileItem in os.listdir(self.projContent):
|
||||
if not fileItem.endswith(".nwd"):
|
||||
logger.warning("Skipping file %s" % fileItem)
|
||||
logger.warning("Skipping file: %s", fileItem)
|
||||
continue
|
||||
if len(fileItem) != 17:
|
||||
logger.warning("Skipping file %s" % fileItem)
|
||||
logger.warning("Skipping file: %s", fileItem)
|
||||
continue
|
||||
fHandle = fileItem[:13]
|
||||
if not isHandle(fHandle):
|
||||
logger.warning("Skipping file %s" % fileItem)
|
||||
logger.warning("Skipping file: %s", fileItem)
|
||||
continue
|
||||
if fHandle in self.projTree:
|
||||
logger.debug("Checking file %s, handle %s: OK" % (fileItem, fHandle))
|
||||
logger.debug("Checking file %s, handle '%s': OK", fileItem, fHandle)
|
||||
else:
|
||||
logger.warning("Checking file %s, handle %s: Orphaned" % (fileItem, fHandle))
|
||||
logger.warning("Checking file %s, handle '%s': Orphaned", fileItem, fHandle)
|
||||
orphanFiles.append(fHandle)
|
||||
|
||||
# Report status
|
||||
@@ -1436,7 +1436,7 @@ class NWProject():
|
||||
sessDiff = self.getSessionWordCount()
|
||||
sessTime = nowTime - self.projOpened
|
||||
|
||||
logger.info("The session lasted %d sec and added %d words" % (int(sessTime), sessDiff))
|
||||
logger.info("The session lasted %d sec and added %d words", int(sessTime), sessDiff)
|
||||
if sessTime < 300 and sessDiff == 0:
|
||||
logger.info("Session too short, skipping log entry")
|
||||
return False
|
||||
@@ -1478,7 +1478,7 @@ class NWProject():
|
||||
errList.append(self.tr("Not a folder: {0}").format(theData))
|
||||
return errList
|
||||
|
||||
logger.info("Old data folder %s found" % theFolder)
|
||||
logger.info("Old data folder %s found", theFolder)
|
||||
|
||||
# Move Documents to Content
|
||||
# =========================
|
||||
@@ -1495,20 +1495,20 @@ class NWProject():
|
||||
newPath = os.path.join(self.projContent, tHandle+".nwd")
|
||||
try:
|
||||
os.rename(theFile, newPath)
|
||||
logger.info("Moved file: %s" % theFile)
|
||||
logger.info("New location: %s" % newPath)
|
||||
logger.info("Moved file: %s", theFile)
|
||||
logger.info("New location: %s", newPath)
|
||||
except Exception:
|
||||
errList.append(self.tr("Could not move: {0}").format(theFile))
|
||||
logger.error("Could not move: %s" % theFile)
|
||||
logger.error("Could not move: %s", theFile)
|
||||
nw.logException()
|
||||
|
||||
elif len(dataItem) == 21 and dataItem.endswith("_main.bak"):
|
||||
try:
|
||||
os.unlink(theFile)
|
||||
logger.info("Deleted file: %s" % theFile)
|
||||
logger.info("Deleted file: %s", theFile)
|
||||
except Exception:
|
||||
errList.append(self.tr("Could not delete: {0}").format(theFile))
|
||||
logger.error("Could not delete: %s" % theFile)
|
||||
logger.error("Could not delete: %s", theFile)
|
||||
nw.logException()
|
||||
|
||||
else:
|
||||
@@ -1520,10 +1520,10 @@ class NWProject():
|
||||
# ==================
|
||||
try:
|
||||
os.rmdir(theData)
|
||||
logger.info("Deleted folder: %s" % theFolder)
|
||||
logger.info("Deleted folder: %s", theFolder)
|
||||
except Exception:
|
||||
errList.append(self.tr("Could not delete: {0}").format(theFolder))
|
||||
logger.error("Could not delete: %s" % theFolder)
|
||||
logger.error("Could not delete: %s", theFolder)
|
||||
nw.logException()
|
||||
|
||||
return errList
|
||||
@@ -1541,9 +1541,9 @@ class NWProject():
|
||||
|
||||
try:
|
||||
os.rename(theSrc, theDst)
|
||||
logger.info("Moved to junk: %s" % theSrc)
|
||||
logger.info("Moved to junk: %s", theSrc)
|
||||
except Exception:
|
||||
logger.error("Could not move item %s to junk." % theSrc)
|
||||
logger.error("Could not move item %s to junk", theSrc)
|
||||
nw.logException()
|
||||
return self.tr("Could not move item {0} to {1}.").format(theSrc, theJunk)
|
||||
|
||||
@@ -1574,11 +1574,11 @@ class NWProject():
|
||||
|
||||
for rmFile in rmList:
|
||||
if os.path.isfile(rmFile):
|
||||
logger.info("Deleting: %s" % rmFile)
|
||||
logger.info("Deleting: %s", rmFile)
|
||||
try:
|
||||
os.unlink(rmFile)
|
||||
except Exception:
|
||||
logger.error("Could not delete: %s" % rmFile)
|
||||
logger.error("Could not delete: %s", rmFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class NWSpellCheck():
|
||||
outFile.write("%s\n" % newWord)
|
||||
self.projDict.append(newWord)
|
||||
except Exception:
|
||||
logger.error("Failed to add word to project word list %s" % str(self.projectDict))
|
||||
logger.error("Failed to add word to project word list %s", str(self.projectDict))
|
||||
nw.logException()
|
||||
return False
|
||||
return True
|
||||
@@ -111,7 +111,7 @@ class NWSpellCheck():
|
||||
theLine = theLine.strip()
|
||||
if len(theLine) > 0 and theLine not in self.projDict:
|
||||
self.projDict.append(theLine)
|
||||
logger.debug("Project word list contains %d words" % len(self.projDict))
|
||||
logger.debug("Project word list contains %d words", len(self.projDict))
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load project word list")
|
||||
@@ -149,10 +149,10 @@ class NWSpellEnchant(NWSpellCheck):
|
||||
self.theBroker = enchant.Broker()
|
||||
self.theDict = self.theBroker.request_dict(theLang)
|
||||
self.spellLanguage = theLang
|
||||
logger.debug("Enchant spell checking for language %s loaded" % theLang)
|
||||
logger.debug("Enchant spell checking for language '%s' loaded", theLang)
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load enchant spell checking for language %s" % theLang)
|
||||
logger.error("Failed to load enchant spell checking for language '%s'", theLang)
|
||||
self.theDict = FakeEnchant()
|
||||
self.spellLanguage = None
|
||||
|
||||
@@ -259,12 +259,12 @@ class NWSpellSimple(NWSpellCheck):
|
||||
continue
|
||||
self.theWords.add(theLine.strip().lower())
|
||||
|
||||
logger.debug("Spell check dictionary for language %s loaded" % theLang)
|
||||
logger.debug("Dictionary contains %d words" % len(self.theWords))
|
||||
logger.debug("Spell check dictionary for language '%s' loaded", theLang)
|
||||
logger.debug("Dictionary contains %d words", len(self.theWords))
|
||||
self.spellLanguage = theLang
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load spell check word list for language %s" % theLang)
|
||||
logger.error("Failed to load spell check word list for language '%s'", theLang)
|
||||
nw.logException()
|
||||
self.spellLanguage = None
|
||||
|
||||
|
||||
+2
-2
@@ -644,7 +644,7 @@ class ToOdt(Tokenizer):
|
||||
"""
|
||||
refStyle = self._mainPara.get(parName, None)
|
||||
if refStyle is None:
|
||||
logger.error("Unknown paragraph style '%s'" % parName)
|
||||
logger.error("Unknown paragraph style '%s'", parName)
|
||||
return "Standard"
|
||||
|
||||
if not refStyle.checkNew(oStyle):
|
||||
@@ -1295,5 +1295,5 @@ def _mkTag(nsName, tagName):
|
||||
theNS = XML_NS.get(nsName, "")
|
||||
if theNS:
|
||||
return "{%s}%s" % (theNS, tagName)
|
||||
logger.warning("Missing xml namespace '%s'" % nsName)
|
||||
logger.warning("Missing xml namespace '%s'", nsName)
|
||||
return tagName
|
||||
|
||||
+14
-13
@@ -111,24 +111,24 @@ class NWTree():
|
||||
tHandle = self._makeHandle()
|
||||
|
||||
if tHandle in self._projTree:
|
||||
logger.warning("Duplicate handle %s detected, skipping" % tHandle)
|
||||
logger.warning("Duplicate handle '%s' detected, skipping", tHandle)
|
||||
return False
|
||||
|
||||
logger.verbose("Adding item %s with parent %s" % (str(tHandle), str(pHandle)))
|
||||
logger.verbose("Adding item '%s' with parent '%s'", str(tHandle), str(pHandle))
|
||||
|
||||
nwItem.setHandle(tHandle)
|
||||
nwItem.setParent(pHandle)
|
||||
|
||||
if nwItem.itemType == nwItemType.ROOT:
|
||||
logger.verbose("Item %s is a root item" % str(tHandle))
|
||||
logger.verbose("Item '%s' is a root item", str(tHandle))
|
||||
self._treeRoots.append(tHandle)
|
||||
if nwItem.itemClass == nwItemClass.ARCHIVE:
|
||||
logger.verbose("Item %s is the archive folder" % str(tHandle))
|
||||
logger.verbose("Item '%s' is the archive folder", str(tHandle))
|
||||
self._archRoot = tHandle
|
||||
|
||||
if nwItem.itemType == nwItemType.TRASH:
|
||||
if self._trashRoot is None:
|
||||
logger.verbose("Item %s is the trash folder" % str(tHandle))
|
||||
logger.verbose("Item '%s' is the trash folder", str(tHandle))
|
||||
self._trashRoot = tHandle
|
||||
else:
|
||||
logger.error("Only one trash folder allowed")
|
||||
@@ -245,9 +245,10 @@ class NWTree():
|
||||
if iLayout in LAYOUT_MAP:
|
||||
if hLevel in LAYOUT_MAP[iLayout]:
|
||||
tItem.itemLayout = LAYOUT_MAP[iLayout][hLevel]
|
||||
logger.debug("Changed layout for %s from %s to %s" % (
|
||||
logger.debug(
|
||||
"Changed layout for %s from %s to %s",
|
||||
tHandle, iLayout.name, tItem.itemLayout.name
|
||||
))
|
||||
)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -357,13 +358,13 @@ class NWTree():
|
||||
if tHandle in self._projTree:
|
||||
tmpOrder.append(tHandle)
|
||||
else:
|
||||
logger.error("Handle %s in new tree order is not in project tree" % tHandle)
|
||||
logger.error("Handle '%s' in new tree order is not in project tree", tHandle)
|
||||
|
||||
# Do a reverse lookup to check for items that will be lost
|
||||
# This is mainly for debugging purposes
|
||||
for tHandle in self._treeOrder:
|
||||
if tHandle not in tmpOrder:
|
||||
logger.warning("Handle %s in old tree order is not in new tree order" % tHandle)
|
||||
logger.warning("Handle '%s' in old tree order is not in new tree order", tHandle)
|
||||
|
||||
# Save the temp list
|
||||
self._treeOrder = tmpOrder
|
||||
@@ -387,7 +388,7 @@ class NWTree():
|
||||
if tItem is None:
|
||||
return False
|
||||
if tItem.itemType != nwItemType.FILE:
|
||||
logger.error("Item %s is not a file" % tHandle)
|
||||
logger.error("Item %s is not a file", tHandle)
|
||||
return False
|
||||
if not isinstance(itemLayout, nwItemLayout):
|
||||
return False
|
||||
@@ -444,7 +445,7 @@ class NWTree():
|
||||
"""
|
||||
if tHandle in self._projTree:
|
||||
return self._projTree[tHandle]
|
||||
logger.error("No tree item with handle %s" % str(tHandle))
|
||||
logger.error("No tree item with handle '%s'", str(tHandle))
|
||||
return None
|
||||
|
||||
def __delitem__(self, tHandle):
|
||||
@@ -454,7 +455,7 @@ class NWTree():
|
||||
self._treeOrder.remove(tHandle)
|
||||
del self._projTree[tHandle]
|
||||
else:
|
||||
logger.warning("Failed to delete item %s: item not found" % tHandle)
|
||||
logger.warning("Failed to delete item '%s': item not found", tHandle)
|
||||
return
|
||||
|
||||
if tHandle in self._treeRoots:
|
||||
@@ -523,7 +524,7 @@ class NWTree():
|
||||
newSeed = str(self._handleSeed)
|
||||
self._handleSeed += 1
|
||||
|
||||
logger.verbose("Generating handle with seed '%s'" % newSeed)
|
||||
logger.verbose("Generating handle with seed '%s'", newSeed)
|
||||
itemHandle = sha256(newSeed.encode()).hexdigest()[0:13]
|
||||
if itemHandle in self._projTree:
|
||||
logger.warning("Duplicate handle encountered! Retrying ...")
|
||||
|
||||
@@ -191,7 +191,7 @@ class GuiDocSplit(QDialog):
|
||||
srcItem.itemName, srcItem.itemClass, srcItem.itemParent
|
||||
)
|
||||
self.theParent.treeView.revealNewTreeItem(fHandle)
|
||||
logger.verbose("Creating folder %s" % fHandle)
|
||||
logger.verbose("Creating folder '%s'", fHandle)
|
||||
|
||||
# Loop through, and create the files
|
||||
for wTitle, iStart, iEnd in finalOrder:
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ def logException():
|
||||
"""Log the content of an exception message.
|
||||
"""
|
||||
exType, exValue, _ = sys.exc_info()
|
||||
logger.error("%s: %s" % (exType.__name__, str(exValue).strip("'")))
|
||||
logger.error("%s: %s", exType.__name__, str(exValue).strip("'"))
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
@@ -159,7 +159,7 @@ def exceptionHandler(exType, exValue, exTrace):
|
||||
from traceback import print_tb
|
||||
from PyQt5.QtWidgets import qApp
|
||||
|
||||
logger.critical("%s: %s" % (exType.__name__, str(exValue)))
|
||||
logger.critical("%s: %s", exType.__name__, str(exValue))
|
||||
print_tb(exTrace)
|
||||
|
||||
try:
|
||||
|
||||
+25
-24
@@ -343,7 +343,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
self._allowAutoReplace(True)
|
||||
afTime = time()
|
||||
logger.debug("Document highlighted in %.3f ms" % (1000*(afTime-bfTime)))
|
||||
logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime))
|
||||
|
||||
self._lastEdit = time()
|
||||
self._lastActive = time()
|
||||
@@ -438,9 +438,9 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
tHandle = self._nwItem.itemHandle
|
||||
if self._docHandle != tHandle:
|
||||
logger.error("Editor handle %s and item handle %s do not match" % (
|
||||
self._docHandle, tHandle
|
||||
))
|
||||
logger.error(
|
||||
"Editor handle '%s' and item handle '%s' do not match", self._docHandle, tHandle
|
||||
)
|
||||
return False
|
||||
|
||||
docText = self.getText()
|
||||
@@ -656,7 +656,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if theBlock:
|
||||
self.setCursorPosition(theBlock.position())
|
||||
self.docFooter.updateLineCount()
|
||||
logger.verbose("Cursor moved to line %d" % theLine)
|
||||
logger.verbose("Cursor moved to line %d", theLine)
|
||||
|
||||
return True
|
||||
|
||||
@@ -703,7 +703,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if not self._bigDoc:
|
||||
self.spellCheckDocument()
|
||||
|
||||
logger.verbose("Spell check is set to %s" % str(theMode))
|
||||
logger.verbose("Spell check is set to '%s'", str(theMode))
|
||||
|
||||
return True
|
||||
|
||||
@@ -723,7 +723,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.hLight.rehighlight()
|
||||
qApp.restoreOverrideCursor()
|
||||
afTime = time()
|
||||
logger.debug("Document highlighted in %.3f ms" % (1000*(afTime-bfTime)))
|
||||
logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime))
|
||||
self.theParent.statusBar.setStatus(self.tr("Spell check complete"))
|
||||
|
||||
return True
|
||||
@@ -739,7 +739,7 @@ class GuiDocEditor(QTextEdit):
|
||||
passed to it without having to consider the internal logic of
|
||||
this class when calling these actions from other classes.
|
||||
"""
|
||||
logger.verbose("Requesting action: %s" % theAction.name)
|
||||
logger.verbose("Requesting action: '%s'", theAction.name)
|
||||
if self._docHandle is None:
|
||||
logger.error("No document open")
|
||||
return False
|
||||
@@ -798,7 +798,7 @@ class GuiDocEditor(QTextEdit):
|
||||
elif theAction == nwDocAction.INDENT_R:
|
||||
self._formatBlock(nwDocAction.INDENT_R)
|
||||
else:
|
||||
logger.debug("Unknown or unsupported document action %s" % str(theAction))
|
||||
logger.debug("Unknown or unsupported document action '%s'", str(theAction))
|
||||
self._allowAutoReplace(True)
|
||||
return False
|
||||
|
||||
@@ -871,15 +871,15 @@ class GuiDocEditor(QTextEdit):
|
||||
If the insert line is not blank, a new line is started.
|
||||
"""
|
||||
if keyWord not in nwKeyWords.VALID_KEYS:
|
||||
logger.error("Invalid keyword '%s'" % keyWord)
|
||||
logger.error("Invalid keyword '%s'", keyWord)
|
||||
return False
|
||||
|
||||
logger.verbose("Inserting keyword '%s'" % keyWord)
|
||||
logger.verbose("Inserting keyword '%s'", keyWord)
|
||||
|
||||
theCursor = self.textCursor()
|
||||
theBlock = theCursor.block()
|
||||
if not theBlock.isValid():
|
||||
logger.error("Failed to insert keyword '%s'" % keyWord)
|
||||
logger.error("Failed to insert keyword '%s'", keyWord)
|
||||
return False
|
||||
|
||||
theCursor.beginEditBlock()
|
||||
@@ -1102,7 +1102,7 @@ class GuiDocEditor(QTextEdit):
|
||||
spellCheck &= theWord != ""
|
||||
|
||||
if spellCheck:
|
||||
logger.verbose("Looking up '%s' in the dictionary" % theWord)
|
||||
logger.verbose("Looking up '%s' in the dictionary", theWord)
|
||||
spellCheck &= not self._theDict.checkWord(theWord)
|
||||
|
||||
if spellCheck:
|
||||
@@ -1154,7 +1154,7 @@ class GuiDocEditor(QTextEdit):
|
||||
wants to add a word to the project dictionary.
|
||||
"""
|
||||
theWord = theCursor.selectedText().strip().strip(self._nonWord)
|
||||
logger.debug("Added '%s' to project dictionary" % theWord)
|
||||
logger.debug("Added '%s' to project dictionary", theWord)
|
||||
self._theDict.addWord(theWord)
|
||||
self.hLight.setDict(self._theDict)
|
||||
self.hLight.rehighlightBlock(theCursor.block())
|
||||
@@ -1215,11 +1215,11 @@ class GuiDocEditor(QTextEdit):
|
||||
QPointF(theSize.width(), theSize.height()), Qt.FuzzyHit
|
||||
)
|
||||
if self._queuePos <= thePos:
|
||||
logger.verbose("Allowed cursor move to %d <= %d" % (self._queuePos, thePos))
|
||||
logger.verbose("Allowed cursor move to %d <= %d", self._queuePos, thePos)
|
||||
self.setCursorPosition(self._queuePos)
|
||||
self._queuePos = None
|
||||
else:
|
||||
logger.verbose("Denied cursor move to %d > %d" % (self._queuePos, thePos))
|
||||
logger.verbose("Denied cursor move to %d > %d", self._queuePos, thePos)
|
||||
return
|
||||
|
||||
##
|
||||
@@ -1350,9 +1350,10 @@ class GuiDocEditor(QTextEdit):
|
||||
theCursor.endEditBlock()
|
||||
theCursor.setPosition(theCursor.selectionEnd())
|
||||
self.setTextCursor(theCursor)
|
||||
logger.verbose("Replaced occurrence of '%s' with '%s' on line %d" % (
|
||||
logger.verbose(
|
||||
"Replaced occurrence of '%s' with '%s' on line %d",
|
||||
searchFor, replWith, theCursor.blockNumber()
|
||||
))
|
||||
)
|
||||
else:
|
||||
logger.error("The selected text is not a search result, skipping replace")
|
||||
|
||||
@@ -1390,10 +1391,10 @@ class GuiDocEditor(QTextEdit):
|
||||
return False
|
||||
|
||||
if loadTag:
|
||||
logger.verbose("Attempting to follow tag '%s'" % theWord)
|
||||
logger.verbose("Attempting to follow tag '%s'", theWord)
|
||||
self.theParent.docViewer.loadFromTag(theWord)
|
||||
else:
|
||||
logger.verbose("Potential tag '%s'" % theWord)
|
||||
logger.verbose("Potential tag '%s'", theWord)
|
||||
|
||||
return True
|
||||
|
||||
@@ -1713,12 +1714,12 @@ class GuiDocEditor(QTextEdit):
|
||||
theCursor = self.textCursor()
|
||||
theBlock = theCursor.block()
|
||||
if not theBlock.isValid():
|
||||
logger.debug("Invalid block selected for action %s" % str(docAction))
|
||||
logger.debug("Invalid block selected for action '%s'", str(docAction))
|
||||
return False
|
||||
|
||||
theText = theBlock.text()
|
||||
if len(theText.strip()) == 0:
|
||||
logger.debug("Empty block selected for action %s" % str(docAction))
|
||||
logger.debug("Empty block selected for action '%s'", str(docAction))
|
||||
return False
|
||||
|
||||
# Remove existing format first, if any
|
||||
@@ -1805,7 +1806,7 @@ class GuiDocEditor(QTextEdit):
|
||||
elif docAction == nwDocAction.BLOCK_TXT:
|
||||
theText = newText
|
||||
else:
|
||||
logger.error("Unknown or unsupported block format requested: %s" % str(docAction))
|
||||
logger.error("Unknown or unsupported block format requested: '%s'", str(docAction))
|
||||
return False
|
||||
|
||||
# Replace the block text
|
||||
@@ -2208,7 +2209,7 @@ class GuiDocEditSearch(QFrame):
|
||||
self.searchBox.selectAll()
|
||||
if self.isRegEx:
|
||||
self._alertSearchValid(True)
|
||||
logger.verbose("Setting search text to '%s'" % theText)
|
||||
logger.verbose("Setting search text to '%s'", theText)
|
||||
return True
|
||||
|
||||
def setReplaceText(self, theText):
|
||||
|
||||
+12
-12
@@ -167,7 +167,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
if tItem.itemType != nwItemType.FILE:
|
||||
return False
|
||||
|
||||
logger.debug("Generating preview for item %s" % tHandle)
|
||||
logger.debug("Generating preview for item '%s'", tHandle)
|
||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
sPos = self.verticalScrollBar().value()
|
||||
@@ -185,7 +185,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
aDoc.doConvert()
|
||||
aDoc.doPostProcessing()
|
||||
except Exception:
|
||||
logger.error("Failed to generate preview for document with handle '%s'" % tHandle)
|
||||
logger.error("Failed to generate preview for document with handle '%s'", tHandle)
|
||||
nw.logException()
|
||||
self.setText(self.tr("An error occurred while generating the preview."))
|
||||
|
||||
@@ -243,7 +243,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
tag rather than a known handle. This function depends on the
|
||||
index being up to date.
|
||||
"""
|
||||
logger.debug("Loading document from tag '%s'" % theTag)
|
||||
logger.debug("Loading document from tag '%s'", theTag)
|
||||
tHandle, _, sTitle = self.theParent.theIndex.getTagSource(theTag)
|
||||
if tHandle is None:
|
||||
self.theParent.makeAlert(self.tr(
|
||||
@@ -258,7 +258,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
# Let the parent handle the opening as it also ensures that
|
||||
# the doc view panel is visible in case this request comes
|
||||
# from outside this class.
|
||||
logger.verbose("Tag points to %s#%s" % (tHandle, sTitle))
|
||||
logger.verbose("Tag points to '%s#%s'", tHandle, sTitle)
|
||||
self.theParent.viewDocument(tHandle, "#%s" % sTitle)
|
||||
return True
|
||||
|
||||
@@ -266,7 +266,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
"""Wrapper function for various document actions on the current
|
||||
document.
|
||||
"""
|
||||
logger.verbose("Requesting action: %s" % theAction.name)
|
||||
logger.verbose("Requesting action: '%s'", theAction.name)
|
||||
if self._docHandle is None:
|
||||
logger.error("No document open")
|
||||
return False
|
||||
@@ -279,7 +279,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
elif theAction == nwDocAction.SEL_PARA:
|
||||
self._makeSelection(QTextCursor.BlockUnderCursor)
|
||||
else:
|
||||
logger.debug("Unknown or unsupported document action %s" % str(theAction))
|
||||
logger.debug("Unknown or unsupported document action '%s'", str(theAction))
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -289,7 +289,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
if not isinstance(tAnchor, str):
|
||||
return False
|
||||
if tAnchor.startswith("#"):
|
||||
logger.verbose("Moving to anchor %s" % tAnchor)
|
||||
logger.verbose("Moving to anchor '%s'", tAnchor)
|
||||
self.setSource(QUrl(tAnchor))
|
||||
return True
|
||||
|
||||
@@ -378,7 +378,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
theBlock = self._qDocument.findBlockByLineNumber(theLine)
|
||||
if theBlock:
|
||||
self.setCursorPosition(theBlock.position())
|
||||
logger.verbose("Cursor moved to line %d" % theLine)
|
||||
logger.verbose("Cursor moved to line %d", theLine)
|
||||
return True
|
||||
|
||||
def setScrollPosition(self, thePos):
|
||||
@@ -410,7 +410,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
"""Slot for a link in the document being clicked.
|
||||
"""
|
||||
theLink = theURL.url()
|
||||
logger.verbose("Clicked link: '%s'" % theLink)
|
||||
logger.verbose("Clicked link: '%s'", theLink)
|
||||
if len(theLink) > 0:
|
||||
theBits = theLink.split("=")
|
||||
if len(theBits) == 2:
|
||||
@@ -617,7 +617,7 @@ class GuiDocViewHistory():
|
||||
|
||||
self._dumpHistory()
|
||||
|
||||
logger.verbose("Added %s to view history" % tHandle)
|
||||
logger.verbose("Added '%s' to view history", tHandle)
|
||||
|
||||
return True
|
||||
|
||||
@@ -1114,7 +1114,7 @@ class GuiDocViewFooter(QWidget):
|
||||
def _doToggleSticky(self, theState):
|
||||
"""Toggle the sticky flag for the reference panel.
|
||||
"""
|
||||
logger.verbose("Reference sticky is %s" % str(theState))
|
||||
logger.verbose("Reference sticky is %s", str(theState))
|
||||
self.docViewer.stickyRef = theState
|
||||
if not theState and self.docViewer.docHandle() is not None:
|
||||
self.viewMeta.refreshReferences(self.docViewer.docHandle())
|
||||
@@ -1210,7 +1210,7 @@ class GuiDocViewDetails(QScrollArea):
|
||||
"""Capture the link-click and forward it to the document viewer
|
||||
class for handling.
|
||||
"""
|
||||
logger.verbose("Clicked link: '%s'" % theLink)
|
||||
logger.verbose("Clicked link: '%s'", theLink)
|
||||
if len(theLink) == 21:
|
||||
tHandle = theLink[:13]
|
||||
tAnchor = theLink[13:]
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
tHandle = theData[0]
|
||||
tLine = checkInt(theData[1], 1)
|
||||
|
||||
logger.verbose("User selected entry with handle %s on line %s" % (tHandle, tLine))
|
||||
logger.verbose("User selected entry with handle '%s' on line %s", tHandle, tLine)
|
||||
self.theParent.openDocument(tHandle, tLine=tLine-1, doScroll=True)
|
||||
|
||||
return
|
||||
|
||||
+6
-6
@@ -212,7 +212,7 @@ class GuiOutline(QTreeWidget):
|
||||
except Exception:
|
||||
tLine = 1
|
||||
|
||||
logger.verbose("User selected entry with handle %s on line %s" % (tHandle, tLine))
|
||||
logger.verbose("User selected entry with handle '%s' on line %s", tHandle, tLine)
|
||||
self.theParent.openDocument(tHandle, tLine=tLine-1, doScroll=True)
|
||||
|
||||
return
|
||||
@@ -248,7 +248,7 @@ class GuiOutline(QTreeWidget):
|
||||
"""Receive the changes to column visibility forwarded by the
|
||||
header context menu.
|
||||
"""
|
||||
logger.verbose("User toggled Outline column '%s'" % theItem.name)
|
||||
logger.verbose("User toggled Outline column '%s'", theItem.name)
|
||||
if theItem in self.colIndex:
|
||||
self.setColumnHidden(self.colIndex[theItem], not isChecked)
|
||||
self._saveHeaderState()
|
||||
@@ -272,7 +272,7 @@ class GuiOutline(QTreeWidget):
|
||||
try:
|
||||
treeOrder.append(nwOutline[hName])
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
logger.warning("Ignored unknown outline column '%s'", str(hName))
|
||||
|
||||
# Add columns that was not in the file to the treeOrder array.
|
||||
for hItem in nwOutline:
|
||||
@@ -285,7 +285,7 @@ class GuiOutline(QTreeWidget):
|
||||
self.treeOrder = treeOrder
|
||||
else:
|
||||
logger.error("Failed to extract outline column order from previous session")
|
||||
logger.error("Column count doesn't match %d != %d" % (len(treeOrder), self.treeNCols))
|
||||
logger.error("Column count doesn't match %d != %d", len(treeOrder), self.treeNCols)
|
||||
|
||||
# We load whatever column widths and hidden states we find in
|
||||
# the file, and leave the rest in their default state.
|
||||
@@ -294,14 +294,14 @@ class GuiOutline(QTreeWidget):
|
||||
try:
|
||||
self.colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
logger.warning("Ignored unknown outline column '%s'", str(hName))
|
||||
|
||||
tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {})
|
||||
for hName in tmpHidden:
|
||||
try:
|
||||
self.colHidden[nwOutline[hName]] = tmpHidden[hName]
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
logger.warning("Ignored unknown outline column '%s'", str(hName))
|
||||
|
||||
self.headerMenu.setHiddenState(self.colHidden)
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ class GuiOutlineDetails(QScrollArea):
|
||||
def _tagClicked(self, theLink):
|
||||
"""Capture the click of a tag in the right-most column.
|
||||
"""
|
||||
logger.verbose("Clicked link: '%s'" % theLink)
|
||||
logger.verbose("Clicked link: '%s'", theLink)
|
||||
if len(theLink) > 0:
|
||||
theBits = theLink.split("=")
|
||||
if len(theBits) == 2:
|
||||
|
||||
+19
-19
@@ -207,8 +207,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
return False
|
||||
|
||||
# Everything is fine, we have what we need, so we proceed
|
||||
logger.verbose("Adding new item of type %s and class %s to handle %s" % (
|
||||
itemType.name, itemClass.name, str(pHandle))
|
||||
logger.verbose(
|
||||
"Adding new item of type '%s' and class '%s' to handle '%s'",
|
||||
itemType.name, itemClass.name, str(pHandle)
|
||||
)
|
||||
|
||||
if itemType == nwItemType.ROOT:
|
||||
@@ -454,7 +455,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if not msgYes:
|
||||
return False
|
||||
|
||||
logger.verbose("Deleting %d file(s) from Trash" % nTrash)
|
||||
logger.verbose("Deleting %d file(s) from Trash", nTrash)
|
||||
for tHandle in self.getTreeFromHandle(trashHandle):
|
||||
if tHandle == trashHandle:
|
||||
continue
|
||||
@@ -496,7 +497,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
wCount = int(trItemS.data(self.C_COUNT, Qt.UserRole))
|
||||
if nwItemS.itemType == nwItemType.FILE:
|
||||
logger.debug("User requested file %s deleted" % tHandle)
|
||||
logger.debug("User requested file '%s' deleted", tHandle)
|
||||
trItemP = trItemS.parent()
|
||||
trItemT = self._addTrashRoot()
|
||||
if trItemP is None or trItemT is None:
|
||||
@@ -519,7 +520,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
doPermanent = True
|
||||
|
||||
if doPermanent:
|
||||
logger.debug("Permanently deleting file with handle %s" % tHandle)
|
||||
logger.debug("Permanently deleting file with handle '%s'", tHandle)
|
||||
|
||||
self.propagateCount(tHandle, 0)
|
||||
tIndex = trItemP.indexOfChild(trItemS)
|
||||
@@ -551,7 +552,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if pHandle is None:
|
||||
logger.warning("File has no parent item")
|
||||
|
||||
logger.debug("Moving file %s to trash" % tHandle)
|
||||
logger.debug("Moving file '%s' to trash", tHandle)
|
||||
|
||||
self.propagateCount(tHandle, 0)
|
||||
tIndex = trItemP.indexOfChild(trItemS)
|
||||
@@ -565,7 +566,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
self._setTreeChanged(True)
|
||||
|
||||
elif nwItemS.itemType == nwItemType.FOLDER:
|
||||
logger.debug("User requested folder %s deleted" % tHandle)
|
||||
logger.debug("User requested folder '%s' deleted", tHandle)
|
||||
trItemP = trItemS.parent()
|
||||
if trItemP is None:
|
||||
logger.error("Could not delete folder")
|
||||
@@ -584,7 +585,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
return False
|
||||
|
||||
elif nwItemS.itemType == nwItemType.ROOT:
|
||||
logger.debug("User requested root folder %s deleted" % tHandle)
|
||||
logger.debug("User requested root folder '%s' deleted", tHandle)
|
||||
tIndex = self.indexOfTopLevelItem(trItemS)
|
||||
if trItemS.childCount() == 0:
|
||||
self.takeTopLevelItem(tIndex)
|
||||
@@ -695,7 +696,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
iCount += 1
|
||||
self._addTreeItem(nwItem)
|
||||
|
||||
logger.debug("%d items added to the project tree" % iCount)
|
||||
logger.debug("%d item(s) added to the project tree", iCount)
|
||||
return True
|
||||
|
||||
def undoLastMove(self):
|
||||
@@ -724,9 +725,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
wCount = int(srcItem.data(self.C_COUNT, Qt.UserRole))
|
||||
sHandle = srcItem.data(self.C_NAME, Qt.UserRole)
|
||||
dHandle = dstItem.data(self.C_NAME, Qt.UserRole)
|
||||
logger.debug("Moving item %s back to %s, index %d" % (
|
||||
sHandle, dHandle, dstIndex
|
||||
))
|
||||
logger.debug("Moving item '%s' back to '%s', index %d", sHandle, dHandle, dstIndex)
|
||||
|
||||
self.propagateCount(sHandle, 0)
|
||||
parItem = srcItem.parent()
|
||||
@@ -882,7 +881,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
allowDrop &= not (self.dropIndicatorPosition() == QAbstractItemView.OnItem and onFile)
|
||||
|
||||
if allowDrop and not isRoot:
|
||||
logger.debug("Drag'n'drop of item %s accepted" % sHandle)
|
||||
logger.debug("Drag'n'drop of item '%s' accepted", sHandle)
|
||||
self.propagateCount(sHandle, 0)
|
||||
QTreeWidget.dropEvent(self, theEvent)
|
||||
self._postItemMove(sHandle, snItem, dnItem, wCount)
|
||||
@@ -890,7 +889,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
else:
|
||||
theEvent.ignore()
|
||||
logger.debug("Drag'n'drop of item %s not accepted" % sHandle)
|
||||
logger.debug("Drag'n'drop of item '%s' not accepted", sHandle)
|
||||
self.makeAlert(self.tr(
|
||||
"The item cannot be moved to that location."
|
||||
), nwAlert.ERROR)
|
||||
@@ -913,9 +912,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
# If the item does not have the same class as the target,
|
||||
# and the target is not a free root folder, update its class
|
||||
if not (isSame or onFree):
|
||||
logger.debug("Item %s class has been changed from %s to %s" % (
|
||||
logger.debug(
|
||||
"Item '%s' class has been changed from '%s' to '%s'",
|
||||
sHandle, snItem.itemClass.name, dnItem.itemClass.name
|
||||
))
|
||||
)
|
||||
snItem.setClass(dnItem.itemClass)
|
||||
self.setTreeItemValues(sHandle)
|
||||
|
||||
@@ -1002,7 +1002,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
try:
|
||||
byIndex = self._treeMap[pHandle].indexOfChild(self._treeMap[nHandle])
|
||||
except Exception:
|
||||
logger.error("Failed to get index of item with handle %s" % nHandle)
|
||||
logger.error("Failed to get index of item with handle '%s'", nHandle)
|
||||
if byIndex >= 0:
|
||||
self._treeMap[pHandle].insertChild(byIndex+1, newItem)
|
||||
else:
|
||||
@@ -1052,14 +1052,14 @@ class GuiProjectTree(QTreeWidget):
|
||||
nwItemS = self.theProject.projTree[tHandle]
|
||||
trItemP = trItemS.parent()
|
||||
if trItemP is None:
|
||||
logger.error("Failed to find new parent item of %s" % tHandle)
|
||||
logger.error("Failed to find new parent item of '%s'", tHandle)
|
||||
return False
|
||||
|
||||
pHandle = trItemP.data(self.C_NAME, Qt.UserRole)
|
||||
nwItemS.setParent(pHandle)
|
||||
self.setTreeItemValues(tHandle)
|
||||
|
||||
logger.debug("The parent of item %s has been changed to %s" % (tHandle, pHandle))
|
||||
logger.debug("The parent of item '%s' has been changed to '%s'", tHandle, pHandle)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
+40
-40
@@ -134,8 +134,8 @@ class GuiTheme:
|
||||
self.guiDPI = qApp.primaryScreen().logicalDotsPerInchX()
|
||||
self.guiScale = qApp.primaryScreen().logicalDotsPerInchX()/96.0
|
||||
self.mainConf.guiScale = self.guiScale
|
||||
logger.verbose("GUI DPI: %.1f" % self.guiDPI)
|
||||
logger.verbose("GUI Scale: %.2f" % self.guiScale)
|
||||
logger.verbose("GUI DPI: %.1f", self.guiDPI)
|
||||
logger.verbose("GUI Scale: %.2f", self.guiScale)
|
||||
|
||||
# Fonts
|
||||
self.guiFont = qApp.font()
|
||||
@@ -152,12 +152,12 @@ class GuiTheme:
|
||||
self.guiFontFixed.setPointSizeF(0.95*self.fontPointSize)
|
||||
self.guiFontFixed.setFamily(QFontDatabase.systemFont(QFontDatabase.FixedFont).family())
|
||||
|
||||
logger.verbose("GUI Font Family: %s" % self.guiFont.family())
|
||||
logger.verbose("GUI Font Point Size: %.2f" % self.fontPointSize)
|
||||
logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize)
|
||||
logger.verbose("GUI Base Icon Size: %d" % self.baseIconSize)
|
||||
logger.verbose("Text 'N' Height: %d" % self.textNHeight)
|
||||
logger.verbose("Text 'N' Width: %d" % self.textNWidth)
|
||||
logger.verbose("GUI Font Family: %s", self.guiFont.family())
|
||||
logger.verbose("GUI Font Point Size: %.2f", self.fontPointSize)
|
||||
logger.verbose("GUI Font Pixel Size: %d", self.fontPixelSize)
|
||||
logger.verbose("GUI Base Icon Size: %d", self.baseIconSize)
|
||||
logger.verbose("Text 'N' Height: %d", self.textNHeight)
|
||||
logger.verbose("Text 'N' Width: %d", self.textNWidth)
|
||||
|
||||
# Internal Mapping
|
||||
self.makeAlert = self.theParent.makeAlert
|
||||
@@ -192,7 +192,7 @@ class GuiTheme:
|
||||
for fontFam in os.listdir(fontAssets):
|
||||
fontDir = os.path.join(fontAssets, fontFam)
|
||||
if os.path.isdir(fontDir):
|
||||
logger.verbose("Found font: %s" % fontFam)
|
||||
logger.verbose("Found font: %s", fontFam)
|
||||
if fontFam not in self.guiFontDB.families():
|
||||
for fontFile in os.listdir(fontDir):
|
||||
ttfFile = os.path.join(fontDir, fontFile)
|
||||
@@ -201,10 +201,10 @@ class GuiTheme:
|
||||
|
||||
for ttfFile in ttfList:
|
||||
relPath = os.path.relpath(ttfFile, fontAssets)
|
||||
logger.verbose("Adding font: %s" % relPath)
|
||||
logger.verbose("Adding font: %s", relPath)
|
||||
fontID = self.guiFontDB.addApplicationFont(ttfFile)
|
||||
if fontID < 0:
|
||||
logger.error("Failed to add font: %s" % relPath)
|
||||
logger.error("Failed to add font: %s", relPath)
|
||||
|
||||
return
|
||||
|
||||
@@ -266,7 +266,7 @@ class GuiTheme:
|
||||
"""Load the currently specified GUI theme.
|
||||
"""
|
||||
logger.debug("Loading theme files")
|
||||
logger.debug("System icon theme is '%s'" % str(QIcon.themeName()))
|
||||
logger.debug("System icon theme is '%s'", str(QIcon.themeName()))
|
||||
|
||||
# CSS File
|
||||
cssData = ""
|
||||
@@ -285,7 +285,7 @@ class GuiTheme:
|
||||
with open(self.confFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load theme settings from: %s" % self.confFile)
|
||||
logger.error("Could not load theme settings from: %s", self.confFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -329,7 +329,7 @@ class GuiTheme:
|
||||
qApp.setStyleSheet(cssData)
|
||||
qApp.setPalette(self.guiPalette)
|
||||
|
||||
logger.info("Loaded theme '%s'" % self.guiTheme)
|
||||
logger.info("Loaded theme '%s'", self.guiTheme)
|
||||
|
||||
return True
|
||||
|
||||
@@ -343,7 +343,7 @@ class GuiTheme:
|
||||
with open(self.syntaxFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load syntax colours from: %s" % self.syntaxFile)
|
||||
logger.error("Could not load syntax colours from: %s", self.syntaxFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -378,7 +378,7 @@ class GuiTheme:
|
||||
self.colRepTag = self._loadColour(confParser, cnfSec, "replacetag")
|
||||
self.colMod = self._loadColour(confParser, cnfSec, "modifier")
|
||||
|
||||
logger.info("Loaded syntax theme '%s'" % self.guiSyntax)
|
||||
logger.info("Loaded syntax theme '%s'", self.guiSyntax)
|
||||
|
||||
return True
|
||||
|
||||
@@ -393,7 +393,7 @@ class GuiTheme:
|
||||
themeConf = os.path.join(
|
||||
self.mainConf.themeRoot, self.guiPath, themeDir, self.confName
|
||||
)
|
||||
logger.verbose("Checking theme config for '%s'" % themeDir)
|
||||
logger.verbose("Checking theme config for '%s'", themeDir)
|
||||
try:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -406,7 +406,7 @@ class GuiTheme:
|
||||
if confParser.has_section("Main"):
|
||||
if confParser.has_option("Main", "name"):
|
||||
themeName = confParser.get("Main", "name")
|
||||
logger.verbose("Theme name is '%s'" % themeName)
|
||||
logger.verbose("Theme name is '%s'", themeName)
|
||||
if themeName != "":
|
||||
self.themeList.append((themeDir, themeName))
|
||||
|
||||
@@ -426,7 +426,7 @@ class GuiTheme:
|
||||
syntaxPath = os.path.join(syntaxDir, syntaxFile)
|
||||
if not os.path.isfile(syntaxPath):
|
||||
continue
|
||||
logger.verbose("Checking theme syntax for '%s'" % syntaxFile)
|
||||
logger.verbose("Checking theme syntax for '%s'", syntaxFile)
|
||||
try:
|
||||
with open(syntaxPath, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -441,7 +441,7 @@ class GuiTheme:
|
||||
syntaxName = confParser.get("Main", "name")
|
||||
if len(syntaxFile) > 5 and syntaxName != "":
|
||||
self.syntaxList.append((syntaxFile[:-5], syntaxName))
|
||||
logger.verbose("Syntax name is '%s'" % syntaxName)
|
||||
logger.verbose("Syntax name is '%s'", syntaxName)
|
||||
|
||||
self.syntaxList = sorted(self.syntaxList, key=lambda x: x[1])
|
||||
|
||||
@@ -462,10 +462,10 @@ class GuiTheme:
|
||||
outData.append(int(inData[1]))
|
||||
outData.append(int(inData[2]))
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
logger.error("Could not load theme colours for '%s' from config file", cnfName)
|
||||
outData = [0, 0, 0]
|
||||
else:
|
||||
logger.warning("Could not find theme colours for '%s' in config file" % cnfName)
|
||||
logger.warning("Could not find theme colours for '%s' in config file", cnfName)
|
||||
outData = [0, 0, 0]
|
||||
return outData
|
||||
|
||||
@@ -480,7 +480,7 @@ class GuiTheme:
|
||||
readCol.append(int(inData[1]))
|
||||
readCol.append(int(inData[2]))
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
logger.error("Could not load theme colours for '%s' from config file", cnfName)
|
||||
return
|
||||
if len(readCol) == 3:
|
||||
self.guiPalette.setColor(paletteVal, QColor(*readCol))
|
||||
@@ -637,7 +637,7 @@ class GuiIcons:
|
||||
self.themeMap = {}
|
||||
checkPath = os.path.join(self.mainConf.iconPath, self.mainConf.guiIcons)
|
||||
if os.path.isdir(checkPath):
|
||||
logger.debug("Loading icon theme '%s'" % self.mainConf.guiIcons)
|
||||
logger.debug("Loading icon theme '%s'", self.mainConf.guiIcons)
|
||||
self.iconPath = checkPath
|
||||
self.confFile = os.path.join(checkPath, self.confName)
|
||||
else:
|
||||
@@ -649,7 +649,7 @@ class GuiIcons:
|
||||
with open(self.confFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load icon theme settings from: %s" % self.confFile)
|
||||
logger.error("Could not load icon theme settings from: %s", self.confFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -669,16 +669,16 @@ class GuiIcons:
|
||||
if confParser.has_section(cnfSec):
|
||||
for iconName, iconFile in confParser.items(cnfSec):
|
||||
if iconName not in self.ICON_MAP:
|
||||
logger.error("Unknown icon name '%s' in config file" % iconName)
|
||||
logger.error("Unknown icon name '%s' in config file", iconName)
|
||||
else:
|
||||
iconPath = os.path.join(self.iconPath, iconFile)
|
||||
if os.path.isfile(iconPath):
|
||||
self.themeMap[iconName] = iconPath
|
||||
logger.verbose("Icon slot '%s' using file '%s'" % (iconName, iconFile))
|
||||
logger.verbose("Icon slot '%s' using file '%s'", iconName, iconFile)
|
||||
else:
|
||||
logger.error("Icon file '%s' not in theme folder" % iconFile)
|
||||
logger.error("Icon file '%s' not in theme folder", iconFile)
|
||||
|
||||
logger.info("Loaded icon theme '%s'" % self.mainConf.guiIcons)
|
||||
logger.info("Loaded icon theme '%s'", self.mainConf.guiIcons)
|
||||
|
||||
return True
|
||||
|
||||
@@ -691,14 +691,14 @@ class GuiIcons:
|
||||
map. This function always returns a QSwgWidget.
|
||||
"""
|
||||
if decoKey not in self.DECO_MAP:
|
||||
logger.error("Decoration with name '%s' does not exist" % decoKey)
|
||||
logger.error("Decoration with name '%s' does not exist", decoKey)
|
||||
return QPixmap()
|
||||
|
||||
imgPath = os.path.join(
|
||||
self.mainConf.assetPath, "images", self.DECO_MAP[decoKey]
|
||||
)
|
||||
if not os.path.isfile(imgPath):
|
||||
logger.error("Decoration file '%s' not in assets folder" % self.DECO_MAP[decoKey])
|
||||
logger.error("Decoration file '%s' not in assets folder", self.DECO_MAP[decoKey])
|
||||
return QPixmap()
|
||||
|
||||
theDeco = QPixmap(imgPath)
|
||||
@@ -742,7 +742,7 @@ class GuiIcons:
|
||||
if not os.path.isdir(themePath) or themeDir == self.fbackName:
|
||||
continue
|
||||
themeConf = os.path.join(themePath, self.confName)
|
||||
logger.verbose("Checking icon theme config for '%s'" % themeDir)
|
||||
logger.verbose("Checking icon theme config for '%s'", themeDir)
|
||||
try:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -755,7 +755,7 @@ class GuiIcons:
|
||||
if confParser.has_section("Main"):
|
||||
if confParser.has_option("Main", "name"):
|
||||
themeName = confParser.get("Main", "name")
|
||||
logger.verbose("Theme name is '%s'" % themeName)
|
||||
logger.verbose("Theme name is '%s'", themeName)
|
||||
if themeName != "":
|
||||
self.themeList.append((themeDir, themeName))
|
||||
|
||||
@@ -774,7 +774,7 @@ class GuiIcons:
|
||||
a QIcon.
|
||||
"""
|
||||
if iconKey not in self.ICON_MAP:
|
||||
logger.error("Requested unknown icon name '%s'" % iconKey)
|
||||
logger.error("Requested unknown icon name '%s'", iconKey)
|
||||
return QIcon()
|
||||
|
||||
# If we just want the app icon, return it right away
|
||||
@@ -785,17 +785,17 @@ class GuiIcons:
|
||||
# First in the theme folder
|
||||
if iconKey in self.themeMap:
|
||||
relPath = os.path.relpath(self.themeMap[iconKey], self.mainConf.iconPath)
|
||||
logger.verbose("Loading: %s" % relPath)
|
||||
logger.verbose("Loading: %s", relPath)
|
||||
return QIcon(self.themeMap[iconKey])
|
||||
|
||||
# Next, we try to load the Qt style icons
|
||||
if self.ICON_MAP[iconKey][0] is not None:
|
||||
logger.verbose("Loading icon '%s' from Qt QStyle.standardIcon" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from Qt QStyle.standardIcon", iconKey)
|
||||
return qApp.style().standardIcon(self.ICON_MAP[iconKey][0])
|
||||
|
||||
# If we're still here, try to set from system theme
|
||||
if self.ICON_MAP[iconKey][1] is not None:
|
||||
logger.verbose("Loading icon '%s' from system theme" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from system theme", iconKey)
|
||||
if QIcon().hasThemeIcon(self.ICON_MAP[iconKey][1]):
|
||||
return QIcon().fromTheme(self.ICON_MAP[iconKey][1])
|
||||
|
||||
@@ -805,16 +805,16 @@ class GuiIcons:
|
||||
self.mainConf.iconPath, self.fbackName, "%s-dark.svg" % iconKey
|
||||
)
|
||||
if os.path.isfile(fbackIcon):
|
||||
logger.verbose("Loading icon '%s' from fallback theme (dark mode)" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from fallback theme (dark mode)", iconKey)
|
||||
return QIcon(fbackIcon)
|
||||
|
||||
fbackIcon = os.path.join(self.mainConf.iconPath, self.fbackName, "%s.svg" % iconKey)
|
||||
if os.path.isfile(fbackIcon):
|
||||
logger.verbose("Loading icon '%s' from fallback theme (light mode)" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from fallback theme (light mode)", iconKey)
|
||||
return QIcon(fbackIcon)
|
||||
|
||||
# Give up and return an empty icon
|
||||
logger.warning("Did not load an icon for '%s'" % iconKey)
|
||||
logger.warning("Did not load an icon for '%s'", iconKey)
|
||||
|
||||
return QIcon()
|
||||
|
||||
|
||||
+22
-22
@@ -68,19 +68,19 @@ class GuiMain(QMainWindow):
|
||||
# System Info
|
||||
# ===========
|
||||
|
||||
logger.info("OS: %s" % self.mainConf.osType)
|
||||
logger.info("Kernel: %s" % self.mainConf.kernelVer)
|
||||
logger.info("Host: %s" % self.mainConf.hostName)
|
||||
logger.info("Qt5 Version: %s (%d)" % (
|
||||
self.mainConf.verQtString, self.mainConf.verQtValue)
|
||||
logger.info("OS: %s", self.mainConf.osType)
|
||||
logger.info("Kernel: %s", self.mainConf.kernelVer)
|
||||
logger.info("Host: %s", self.mainConf.hostName)
|
||||
logger.info(
|
||||
"Qt5 Version: %s (%d)", self.mainConf.verQtString, self.mainConf.verQtValue
|
||||
)
|
||||
logger.info("PyQt5 Version: %s (%d)" % (
|
||||
self.mainConf.verPyQtString, self.mainConf.verPyQtValue)
|
||||
logger.info(
|
||||
"PyQt5 Version: %s (%d)", self.mainConf.verPyQtString, self.mainConf.verPyQtValue
|
||||
)
|
||||
logger.info("Python Version: %s (0x%x)" % (
|
||||
self.mainConf.verPyString, self.mainConf.verPyHexVal)
|
||||
logger.info(
|
||||
"Python Version: %s (0x%x)", self.mainConf.verPyString, self.mainConf.verPyHexVal
|
||||
)
|
||||
logger.info("GUI Language: %s" % self.mainConf.guiLang)
|
||||
logger.info("GUI Language: %s", self.mainConf.guiLang)
|
||||
|
||||
# Core Classes
|
||||
# ============
|
||||
@@ -680,7 +680,7 @@ class GuiMain(QMainWindow):
|
||||
# Make sure main tab is in Editor view
|
||||
self.mainTabs.setCurrentWidget(self.splitDocs)
|
||||
|
||||
logger.debug("Viewing document with handle %s" % tHandle)
|
||||
logger.debug("Viewing document with handle '%s'", tHandle)
|
||||
if self.docViewer.loadText(tHandle):
|
||||
if not self.splitView.isVisible():
|
||||
bPos = self.splitMain.sizes()
|
||||
@@ -805,13 +805,13 @@ class GuiMain(QMainWindow):
|
||||
logger.warning("No item selected")
|
||||
return False
|
||||
|
||||
logger.verbose("Opening item %s" % tHandle)
|
||||
logger.verbose("Opening item '%s'", tHandle)
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
if nwItem.itemType == nwItemType.FILE:
|
||||
logger.verbose("Requested item %s is a file" % tHandle)
|
||||
logger.verbose("Requested item '%s' is a file", tHandle)
|
||||
self.openDocument(tHandle, doScroll=False)
|
||||
else:
|
||||
logger.verbose("Requested item %s is not a file" % tHandle)
|
||||
logger.verbose("Requested item '%s' is not a file", tHandle)
|
||||
|
||||
return True
|
||||
|
||||
@@ -838,7 +838,7 @@ class GuiMain(QMainWindow):
|
||||
if tItem.itemType not in nwLists.REG_TYPES:
|
||||
return
|
||||
|
||||
logger.verbose("Requesting change to item %s" % tHandle)
|
||||
logger.verbose("Requesting change to item '%s'", tHandle)
|
||||
dlgProj = GuiItemEditor(self, tHandle)
|
||||
dlgProj.exec_()
|
||||
if dlgProj.result() == QDialog.Accepted:
|
||||
@@ -888,7 +888,7 @@ class GuiMain(QMainWindow):
|
||||
self.setStatus(self.tr("Indexing: '{0}'").format(self.tr("Unknown item")))
|
||||
|
||||
if tItem is not None and tItem.itemType == nwItemType.FILE:
|
||||
logger.verbose("Scanning: %s" % tItem.itemName)
|
||||
logger.verbose("Scanning '%s'", tItem.itemName)
|
||||
self.theIndex.reIndexHandle(tItem.itemHandle)
|
||||
|
||||
# Get Word Counts
|
||||
@@ -1513,15 +1513,15 @@ class GuiMain(QMainWindow):
|
||||
we open it. Otherwise, we do nothing.
|
||||
"""
|
||||
tHandle = tItem.data(self.treeView.C_NAME, Qt.UserRole)
|
||||
logger.verbose("User double clicked tree item with handle %s" % tHandle)
|
||||
logger.verbose("User double clicked tree item with handle '%s'", tHandle)
|
||||
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
if nwItem is not None:
|
||||
if nwItem.itemType == nwItemType.FILE:
|
||||
logger.verbose("Requested item %s is a file" % tHandle)
|
||||
logger.verbose("Requested item '%s' is a file", tHandle)
|
||||
self.openDocument(tHandle, changeFocus=False, doScroll=False)
|
||||
else:
|
||||
logger.verbose("Requested item %s is a folder" % tHandle)
|
||||
logger.verbose("Requested item '%s' is a folder", tHandle)
|
||||
|
||||
return
|
||||
|
||||
@@ -1545,15 +1545,15 @@ class GuiMain(QMainWindow):
|
||||
not change focus to the editor as double click does.
|
||||
"""
|
||||
tHandle = self.treeView.getSelectedHandle()
|
||||
logger.verbose("User pressed return on tree item with handle %s" % tHandle)
|
||||
logger.verbose("User pressed return on tree item with handle '%s'", tHandle)
|
||||
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
if nwItem is not None:
|
||||
if nwItem.itemType == nwItemType.FILE:
|
||||
logger.verbose("Requested item %s is a file" % tHandle)
|
||||
logger.verbose("Requested item '%s' is a file", tHandle)
|
||||
self.openDocument(tHandle, changeFocus=False, doScroll=False)
|
||||
else:
|
||||
logger.verbose("Requested item %s is a folder" % tHandle)
|
||||
logger.verbose("Requested item '%s' is a folder", tHandle)
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user