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
+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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user