Further PEP8 compliance changes

This commit is contained in:
Veronica K. B. Olsen
2019-11-03 18:02:47 +01:00
parent 7c95af951a
commit b303eb6539
37 changed files with 408 additions and 380 deletions
+12 -6
View File
@@ -17,16 +17,20 @@ logger = logging.getLogger(__name__)
def checkString(checkValue, defaultValue, allowNone=False):
if allowNone:
if checkValue == None: return None
if checkValue == "None": return None
if checkValue == None:
return None
if checkValue == "None":
return None
if isinstance(checkValue,str):
return str(checkValue)
return defaultValue
def checkInt(checkValue, defaultValue, allowNone=False):
if allowNone:
if checkValue == None: return None
if checkValue == "None": return None
if checkValue == None:
return None
if checkValue == "None":
return None
try:
return int(checkValue)
except:
@@ -34,8 +38,10 @@ def checkInt(checkValue, defaultValue, allowNone=False):
def checkBool(checkValue, defaultValue, allowNone=False):
if allowNone:
if checkValue == None: return None
if checkValue == "None": return None
if checkValue == None:
return None
if checkValue == "None":
return None
if isinstance(checkValue, str):
if checkValue == "True":
return True
+3 -3
View File
@@ -19,12 +19,12 @@ from os import path, mkdir, makedirs, getcwd
from appdirs import user_config_dir
from datetime import datetime
from nw.constants import nwFiles, nwUnicode
from nw.common import splitVersionNumber
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import QT_VERSION_STR
from nw.constants import nwFiles, nwUnicode
from nw.common import splitVersionNumber
logger = logging.getLogger(__name__)
class Config:
+1 -2
View File
@@ -14,6 +14,7 @@ import logging
import nw
from os import path
from PyQt5.QtWidgets import QMessageBox
from nw.convert.file.text import TextFile
@@ -26,9 +27,7 @@ class ConcatFile(TextFile):
def __init__(self, theProject, theParent):
TextFile.__init__(self, theProject, theParent)
self.theConv = Tokenizer(self.theProject, self.theParent)
return
def addText(self, tHandle):
-2
View File
@@ -23,9 +23,7 @@ class HtmlFile(TextFile):
def __init__(self, theProject, theParent):
TextFile.__init__(self, theProject, theParent)
self.theConv = ToHtml(self.theProject, self.theParent)
return
##
-5
View File
@@ -32,7 +32,6 @@ class LaTeXFile(TextFile):
##
def _doOpenFile(self, filePath):
try:
self.outFile = open(filePath,mode="wt+",encoding="utf8")
self.outFile.write("\\documentclass[12pt]{report}\n")
@@ -43,17 +42,13 @@ class LaTeXFile(TextFile):
except Exception as e:
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
return False
return True
def _doCloseFile(self):
if self.outFile is not None:
self.outFile.write("\\end{document}\n")
self.outFile.close()
self.texCodecFail = self.theConv.texCodecFail
return True
# END Class LaTeXFile
-2
View File
@@ -23,9 +23,7 @@ class MarkdownFile(TextFile):
def __init__(self, theProject, theParent):
TextFile.__init__(self, theProject, theParent)
self.theConv = ToMarkdown(self.theProject, self.theParent)
return
##
+1
View File
@@ -14,6 +14,7 @@ import logging
import nw
from os import path
from PyQt5.QtWidgets import QMessageBox
from nw.convert.text.totext import ToText
-2
View File
@@ -31,12 +31,10 @@ class ToHtml(Tokenizer):
need to make a few changes to formatting, which is selected by
this flag.
"""
self.forPreview = forPreview
if forPreview:
self.doKeywords = True
self.doComments = doComments
return
def doAutoReplace(self):
+2 -1
View File
@@ -230,7 +230,8 @@ class Tokenizer():
if isNone: return
if isNote: return
# For novel files, we need to handle chapter numbering and scene breaks
# For novel files, we need to handle chapter numbering and scene
# breaks
if isBook or isUnNum or isChap or isScene:
for n in range(len(self.theTokens)):
+12 -4
View File
@@ -557,25 +557,33 @@ class GuiConfigEditEditor(QWidget):
if self._checkQuoteSymbol(fmtSingleQuotesO):
self.mainConf.fmtSingleQuotes[0] = fmtSingleQuotesO
else:
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtSingleQuotesO, nwAlert.ERROR)
self.theParent.makeAlert(
"Invalid quote symbol: %s" % fmtSingleQuotesO, nwAlert.ERROR
)
validEntries = False
if self._checkQuoteSymbol(fmtSingleQuotesC):
self.mainConf.fmtSingleQuotes[1] = fmtSingleQuotesC
else:
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtSingleQuotesC, nwAlert.ERROR)
self.theParent.makeAlert(
"Invalid quote symbol: %s" % fmtSingleQuotesC, nwAlert.ERROR
)
validEntries = False
if self._checkQuoteSymbol(fmtDoubleQuotesO):
self.mainConf.fmtDoubleQuotes[0] = fmtDoubleQuotesO
else:
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtDoubleQuotesO, nwAlert.ERROR)
self.theParent.makeAlert(
"Invalid quote symbol: %s" % fmtDoubleQuotesO, nwAlert.ERROR
)
validEntries = False
if self._checkQuoteSymbol(fmtDoubleQuotesC):
self.mainConf.fmtDoubleQuotes[1] = fmtDoubleQuotesC
else:
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtDoubleQuotesC, nwAlert.ERROR)
self.theParent.makeAlert(
"Invalid quote symbol: %s" % fmtDoubleQuotesC, nwAlert.ERROR
)
validEntries = False
showTabsNSpaces = self.showTabsNSpaces.isChecked()
+24 -21
View File
@@ -19,8 +19,9 @@ from os import path
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout, QGroupBox, QCheckBox,
QLabel, QComboBox, QLineEdit, QPushButton, QFileDialog, QProgressBar, QSpinBox, QMessageBox
QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout,
QGroupBox, QCheckBox, QLabel, QComboBox, QLineEdit, QPushButton,
QFileDialog, QProgressBar, QSpinBox, QMessageBox
)
from nw.project.document import NWDoc
@@ -201,9 +202,10 @@ class GuiExport(QDialog):
# Check that encoding was successful
if outFile.texCodecFail:
self.theParent.makeAlert((
"Failed to escape unicode characters while writing LaTeX file. The generated "
".tex file may not build properly. Make sure the python package '{package:s}' "
"is installed and working."
"Failed to escape unicode characters while writing LaTeX "
"file. The generated .tex file may not build properly. "
"Make sure the python package '{package:s}' is installed "
"and working."
).format(
package = packageRefURL("latexcodec")
), nwAlert.WARN)
@@ -343,27 +345,31 @@ class GuiExportMain(QWidget):
}
FMT_HELP = {
FMT_NWD : (
"Exports a document using the novelWriter markdown format. The files selected by the "
"filters are appended as-is, including comments and other settings."
"Exports a document using the novelWriter markdown format. "
"The files selected by the filters are appended as-is, "
"including comments and other settings."
),
FMT_TXT : (
"Exports a plain text file. All formatting is stripped and comments are in square "
"brackets."
"Exports a plain text file. All formatting is stripped and "
"comments are in square brackets."
),
FMT_MD : (
"Exports a standard markdown file. Comments are converted to preformatted text blocks."
"Exports a standard markdown file. Comments are converted "
"to preformatted text blocks."
),
FMT_HTML : (
"Exports a plain html5 file. Comments are wrapped in blocks with a yellow background "
"colour."
"Exports a plain html5 file. Comments are wrapped in "
"blocks with a yellow background colour."
),
FMT_TEX : (
"Exports a LaTeX file that can be compiled to PDF using for instance PDFLaTeX. "
"Comments are exported as LaTeX comments."
"Exports a LaTeX file that can be compiled to PDF using "
"for instance PDFLaTeX. Comments are exported as LaTeX "
"comments."
),
FMT_PDOC : (
"Exports first to markdown or html5. The file is then passed on to Pandoc for a "
"second stage. Use the Pandoc tab for settings up the conversion."
"Exports first to markdown or html5. The file is then "
"passed on to Pandoc for a second stage. Use the Pandoc "
"tab for settings up the conversion."
),
}
@@ -566,7 +572,8 @@ class GuiExportMain(QWidget):
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
saveTo = QFileDialog.getSaveFileName(
self,"Export File",self.exportPath.text(),options=dlgOpt,filter=";;".join(extFilter)
self, "Export File", self.exportPath.text(),
options=dlgOpt, filter=";;".join(extFilter)
)
if saveTo:
self.exportPath.setText(saveTo[0])
@@ -658,7 +665,6 @@ class GuiExportPandoc(QWidget):
self.outputFormat.addItem("ePUB eBook v2 (.epub2)", self.FMT_EPUB2)
self.outputFormat.addItem("ePUB eBook v3 (.epub3)", self.FMT_EPUB3)
self.outputFormat.addItem("Zim Wiki (.txt)", self.FMT_ZIM)
# self.outputFormat.currentIndexChanged.connect(self._updateFormat)
optIdx = self.outputFormat.findData(self.optState.getSetting("pFormat"))
if optIdx == -1:
@@ -674,9 +680,6 @@ class GuiExportPandoc(QWidget):
self.outerBox.addWidget(self.guiInfo, 0, 0)
self.outerBox.addWidget(self.guiOutput, 1, 0)
self.outerBox.setRowStretch(2, 1)
# self.outerBox.setColumnStretch(0, 1)
# self.outerBox.setColumnStretch(1, 1)
# self.outerBox.setColumnStretch(2, 1)
self.setLayout(self.outerBox)
return
+2 -1
View File
@@ -18,7 +18,8 @@ from os import path
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox
QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout,
QLineEdit, QPushButton, QComboBox
)
from nw.enum import nwItemLayout, nwItemClass, nwItemType
+4 -3
View File
@@ -19,9 +19,10 @@ from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush, QStandardItemModel
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QLabel,
QWidget, QTabWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QPushButton,
QColorDialog, QAbstractItemView, QTreeWidget, QTreeWidgetItem, QCheckBox
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit,
QLabel, QWidget, QTabWidget, QDialogButtonBox, QListWidget,
QListWidgetItem, QPushButton, QColorDialog, QAbstractItemView, QTreeWidget,
QTreeWidgetItem, QCheckBox
)
from nw.enum import nwAlert
+4 -2
View File
@@ -15,11 +15,13 @@ import nw
from os import path
from datetime import datetime
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QColor, QPixmap, QFont
from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QHeaderView,
QGridLayout, QLabel, QGroupBox, QCheckBox
QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QTreeWidgetItem,
QDialogButtonBox, QHeaderView, QGridLayout, QLabel, QGroupBox,
QCheckBox
)
from nw.tools.optlaststate import OptLastState
+3 -2
View File
@@ -18,8 +18,9 @@ from os import path
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QColor, QPixmap
from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem, QDialogButtonBox, QLabel,
QPushButton, QHeaderView, QGridLayout, QGroupBox, QCheckBox
QDialog, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem,
QDialogButtonBox, QLabel, QPushButton, QHeaderView, QGridLayout,
QGroupBox, QCheckBox
)
from nw.tools.optlaststate import OptLastState
+11 -8
View File
@@ -16,9 +16,12 @@ import nw
from time import time
from PyQt5.QtCore import Qt, QTimer, QSizeF
from PyQt5.QtWidgets import qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox
from PyQt5.QtWidgets import (
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox
)
from PyQt5.QtGui import (
QTextCursor, QTextOption, QIcon, QKeySequence, QFont, QColor, QPalette, QTextDocument,
QTextCursor, QTextOption, QIcon, QKeySequence, QFont, QColor,
QPalette, QTextDocument,
)
from nw.project.document import NWDoc
@@ -85,20 +88,20 @@ class GuiDocEditor(QTextEdit):
QShortcut(
QKeySequence("Ctrl+."),
self,
context = Qt.WidgetShortcut,
activated = self._openSpellContext
context=Qt.WidgetShortcut,
activated=self._openSpellContext
)
QShortcut(
Qt.Key_Return | Qt.ControlModifier,
self,
context = Qt.WidgetShortcut,
activated = self._followTag
context=Qt.WidgetShortcut,
activated=self._followTag
)
QShortcut(
Qt.Key_Enter | Qt.ControlModifier,
self,
context = Qt.WidgetShortcut,
activated = self._followTag
context=Qt.WidgetShortcut,
activated=self._followTag
)
# Set Up Word Count Thread and Timer
+3 -1
View File
@@ -15,7 +15,9 @@ import nw
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon, QFont, QColor
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication
from PyQt5.QtWidgets import (
QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication
)
from nw.project.item import NWItem
from nw.constants import nwLabels
+1
View File
@@ -37,6 +37,7 @@ class GuiNoticeBar(QFrame):
self.mainBox.setContentsMargins(8,2,2,2)
self.noteLabel = QLabel("Hi there!")
self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
self.closeButton.clicked.connect(self.hideNote)
+3 -1
View File
@@ -15,7 +15,9 @@ import nw
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication
from PyQt5.QtWidgets import (
QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication
)
from nw.enum import nwDocAction
+2 -2
View File
@@ -16,8 +16,8 @@ import nw
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (
QWidget, QHBoxLayout, QVBoxLayout, QLabel, QGroupBox, QScrollArea, QFrame, QToolButton,
QSizePolicy, QCheckBox, QGridLayout
QWidget, QHBoxLayout, QVBoxLayout, QLabel, QGroupBox, QScrollArea, QFrame,
QToolButton, QSizePolicy, QCheckBox, QGridLayout
)
from nw.constants import nwLabels
+3 -1
View File
@@ -78,7 +78,9 @@ class GuiMainMenu(QMenuBar):
recentProject = self.mainConf.recentList[n]
if recentProject == "": continue
menuItem = QAction("%s" % recentProject, self.projMenu)
menuItem.triggered.connect(lambda menuItem, n=n : self.openRecentProject(menuItem, n))
menuItem.triggered.connect(
lambda menuItem, n=n : self.openRecentProject(menuItem, n)
)
self.recentMenu.addAction(menuItem)
self.recentMenu.addSeparator()
+1
View File
@@ -14,6 +14,7 @@ import logging
import nw
from time import time
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QIcon, QColor, QPixmap
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
+4 -2
View File
@@ -14,7 +14,9 @@ import logging
import nw
from PyQt5.QtCore import Qt, QRegularExpression
from PyQt5.QtGui import QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
)
from nw.constants import nwUnicode
@@ -196,7 +198,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
))
self.hRules.append((
"<(\S+?)>", {
r"<(\S+?)>", {
0 : self.hStyles["replace"],
}
))
+5 -5
View File
@@ -168,13 +168,13 @@ class GuiMain(QMainWindow):
QShortcut(
Qt.Key_Return,
self.treeView,
context = Qt.WidgetShortcut,
activated = self._treeKeyPressReturn
context=Qt.WidgetShortcut,
activated=self._treeKeyPressReturn
)
QShortcut(
Qt.Key_Escape,
self,
activated = self._keyPressEscape
activated=self._keyPressEscape
)
# Forward Functions
@@ -578,7 +578,7 @@ class GuiMain(QMainWindow):
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath = QFileDialog.getExistingDirectory(
self,"Save novelWriter Project","",options=dlgOpt
self, "Save novelWriter Project", "", options=dlgOpt
)
if projPath:
return projPath
@@ -589,7 +589,7 @@ class GuiMain(QMainWindow):
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath = QFileDialog.getExistingDirectory(
self,"Select Location for New novelWriter Project","",options=dlgOpt
self, "Select Location for New novelWriter Project", "", options=dlgOpt
)
if projPath:
return projPath
+6 -3
View File
@@ -103,9 +103,12 @@ class NWDoc():
docTemp = path.join(dataPath,docFile[:-3]+"tmp")
docBack = path.join(dataPath,docFile[:-3]+"bak")
if path.isfile(docTemp): unlink(docTemp)
if path.isfile(docBack): rename(docBack,docTemp)
if path.isfile(docPath): rename(docPath,docBack)
if path.isfile(docTemp):
unlink(docTemp)
if path.isfile(docBack):
rename(docBack,docTemp)
if path.isfile(docPath):
rename(docPath,docBack)
try:
with open(docPath,mode="w",encoding="utf8") as outFile:
-2
View File
@@ -390,7 +390,6 @@ class NWIndex():
def buildNovelList(self):
"""Build a list of the content of the novel.
"""
self.novelList = []
self.novelOrder = []
for tHandle in self.theProject.treeOrder:
@@ -399,7 +398,6 @@ class NWIndex():
for tEntry in self.novelIndex[tHandle]:
self.novelList.append(tEntry)
self.novelOrder.append("%s:%d" % (tHandle,tEntry[0]))
return True
def buildReferenceList(self, tHandle):
+21 -19
View File
@@ -194,8 +194,10 @@ class NWProject():
self.projCache = path.join(self.projPath,"cache")
self.projDict = path.join(self.projMeta, nwFiles.PROJ_DICT)
if not self._checkFolder(self.projMeta): return
if not self._checkFolder(self.projCache): return
if not self._checkFolder(self.projMeta):
return
if not self._checkFolder(self.projCache):
return
try:
nwXML = etree.parse(fileName)
@@ -313,19 +315,19 @@ class NWProject():
})
# Save Project Meta
xProject = etree.SubElement(nwXML,"project")
self._saveProjectValue(xProject,"name", self.projName, True)
self._saveProjectValue(xProject,"title", self.bookTitle, True)
self._saveProjectValue(xProject,"author",self.bookAuthors)
self._saveProjectValue(xProject,"backup",self.doBackup)
xProject = etree.SubElement(nwXML, "project")
self._saveProjectValue(xProject, "name", self.projName, True)
self._saveProjectValue(xProject, "title", self.bookTitle, True)
self._saveProjectValue(xProject, "author", self.bookAuthors)
self._saveProjectValue(xProject, "backup", self.doBackup)
# Save Project Settings
xSettings = etree.SubElement(nwXML,"settings")
self._saveProjectValue(xSettings,"spellCheck", self.spellCheck)
self._saveProjectValue(xSettings,"lastEdited", self.lastEdited)
self._saveProjectValue(xSettings,"lastViewed", self.lastViewed)
self._saveProjectValue(xSettings,"lastWordCount",self.currWCount)
xAutoRep = etree.SubElement(xSettings,"autoReplace")
xSettings = etree.SubElement(nwXML, "settings")
self._saveProjectValue(xSettings, "spellCheck", self.spellCheck)
self._saveProjectValue(xSettings, "lastEdited", self.lastEdited)
self._saveProjectValue(xSettings, "lastViewed", self.lastViewed)
self._saveProjectValue(xSettings, "lastWordCount", self.currWCount)
xAutoRep = etree.SubElement(xSettings, "autoReplace")
for aKey, aValue in self.autoReplace.items():
if len(aKey) > 0:
self._saveProjectValue(xAutoRep,aKey,aValue)
@@ -337,7 +339,7 @@ class NWProject():
# Save Tree Content
logger.debug("Writing project content")
xContent = etree.SubElement(nwXML,"content",attrib={"count":str(len(self.treeOrder))})
xContent = etree.SubElement(nwXML, "content", attrib={"count":str(len(self.treeOrder))})
for tHandle in self.treeOrder:
self.projTree[tHandle].packXML(xContent)
@@ -411,8 +413,8 @@ class NWProject():
return False
if self.projName == "":
self.theParent.makeAlert((
"You must set a valid project name in project settings to use "
"the automatic project backup feature."
"You must set a valid project name in project settings to "
"use the automatic project backup feature."
), nwAlert.ERROR)
return False
self.doBackup = True
@@ -699,7 +701,7 @@ class NWProject():
sessionFile = path.join(self.projMeta, nwFiles.SESS_INFO)
with open(sessionFile,mode="a+",encoding="utf8") as outFile:
with open(sessionFile, mode="a+", encoding="utf8") as outFile:
print((
"Start: {opened:s} "
"End: {closed:s} "
@@ -750,8 +752,8 @@ class NWProject():
try:
copyfile(
path.join(self.projPath,self.projFile),
path.join(self.projCache,projBackup)
path.join(self.projPath, self.projFile),
path.join(self.projCache, projBackup)
)
except:
logger.error("Failed to write to file %s" % projBackup)
+44 -44
View File
@@ -162,36 +162,36 @@ class Theme:
## Main
cnfSec = "Main"
if confParser.has_section(cnfSec):
self.themeName = self._parseLine(confParser,cnfSec,"name", "")
self.themeAuthor = self._parseLine(confParser,cnfSec,"author","")
self.themeCredit = self._parseLine(confParser,cnfSec,"credit","")
self.themeUrl = self._parseLine(confParser,cnfSec,"url", "")
self.themeName = self._parseLine( confParser, cnfSec, "name", "")
self.themeAuthor = self._parseLine( confParser, cnfSec, "author", "")
self.themeCredit = self._parseLine( confParser, cnfSec, "credit", "")
self.themeUrl = self._parseLine( confParser, cnfSec, "url", "")
## Palette
cnfSec = "Palette"
if confParser.has_section(cnfSec):
self._setPalette(confParser,cnfSec,"window", QPalette.Window)
self._setPalette(confParser,cnfSec,"windowtext", QPalette.WindowText)
self._setPalette(confParser,cnfSec,"base", QPalette.Base)
self._setPalette(confParser,cnfSec,"alternatebase", QPalette.AlternateBase)
self._setPalette(confParser,cnfSec,"text", QPalette.Text)
self._setPalette(confParser,cnfSec,"tooltipbase", QPalette.ToolTipBase)
self._setPalette(confParser,cnfSec,"tooltiptext", QPalette.ToolTipText)
self._setPalette(confParser,cnfSec,"button", QPalette.Button)
self._setPalette(confParser,cnfSec,"buttontext", QPalette.ButtonText)
self._setPalette(confParser,cnfSec,"brighttext", QPalette.BrightText)
self._setPalette(confParser,cnfSec,"highlight", QPalette.Highlight)
self._setPalette(confParser,cnfSec,"highlightedtext",QPalette.HighlightedText)
self._setPalette(confParser,cnfSec,"link", QPalette.Link)
self._setPalette(confParser,cnfSec,"linkvisited", QPalette.LinkVisited)
self._setPalette(confParser, cnfSec, "window", QPalette.Window)
self._setPalette(confParser, cnfSec, "windowtext", QPalette.WindowText)
self._setPalette(confParser, cnfSec, "base", QPalette.Base)
self._setPalette(confParser, cnfSec, "alternatebase", QPalette.AlternateBase)
self._setPalette(confParser, cnfSec, "text", QPalette.Text)
self._setPalette(confParser, cnfSec, "tooltipbase", QPalette.ToolTipBase)
self._setPalette(confParser, cnfSec, "tooltiptext", QPalette.ToolTipText)
self._setPalette(confParser, cnfSec, "button", QPalette.Button)
self._setPalette(confParser, cnfSec, "buttontext", QPalette.ButtonText)
self._setPalette(confParser, cnfSec, "brighttext", QPalette.BrightText)
self._setPalette(confParser, cnfSec, "highlight", QPalette.Highlight)
self._setPalette(confParser, cnfSec, "highlightedtext", QPalette.HighlightedText)
self._setPalette(confParser, cnfSec, "link", QPalette.Link)
self._setPalette(confParser, cnfSec, "linkvisited", QPalette.LinkVisited)
## GUI
cnfSec = "GUI"
if confParser.has_section(cnfSec):
self.treeWCount = self._loadColour(confParser,cnfSec,"treewordcount")
self.statNone = self._loadColour(confParser,cnfSec,"statusnone")
self.statUnsaved = self._loadColour(confParser,cnfSec,"statusunsaved")
self.statSaved = self._loadColour(confParser,cnfSec,"statussaved")
self.treeWCount = self._loadColour(confParser, cnfSec, "treewordcount")
self.statNone = self._loadColour(confParser, cnfSec, "statusnone")
self.statUnsaved = self._loadColour(confParser, cnfSec, "statusunsaved")
self.statSaved = self._loadColour(confParser, cnfSec, "statussaved")
# Apply Styles
qApp.setStyleSheet(cssData)
@@ -205,7 +205,7 @@ class Theme:
confParser = configparser.ConfigParser()
try:
confParser.read_file(open(self.syntaxFile,mode="r",encoding="utf8"))
confParser.read_file(open(self.syntaxFile, mode="r", encoding="utf8"))
except Exception as e:
logger.error("Could not load syntax colours from: %s" % self.syntaxFile)
return False
@@ -213,29 +213,29 @@ class Theme:
## Main
cnfSec = "Main"
if confParser.has_section(cnfSec):
self.syntaxName = self._parseLine(confParser,cnfSec,"name","")
self.syntaxAuthor = self._parseLine(confParser,cnfSec,"author","")
self.syntaxCredit = self._parseLine(confParser,cnfSec,"credit","")
self.syntaxUrl = self._parseLine(confParser,cnfSec,"url", "")
self.syntaxName = self._parseLine(confParser, cnfSec, "name", "")
self.syntaxAuthor = self._parseLine(confParser, cnfSec, "author", "")
self.syntaxCredit = self._parseLine(confParser, cnfSec, "credit", "")
self.syntaxUrl = self._parseLine(confParser, cnfSec, "url", "")
## Syntax
cnfSec = "Syntax"
if confParser.has_section(cnfSec):
self.colBack = self._loadColour(confParser,cnfSec,"background")
self.colText = self._loadColour(confParser,cnfSec,"text")
self.colLink = self._loadColour(confParser,cnfSec,"link")
self.colHead = self._loadColour(confParser,cnfSec,"headertext")
self.colHeadH = self._loadColour(confParser,cnfSec,"headertag")
self.colEmph = self._loadColour(confParser,cnfSec,"emphasis")
self.colDialN = self._loadColour(confParser,cnfSec,"straightquotes")
self.colDialD = self._loadColour(confParser,cnfSec,"doublequotes")
self.colDialS = self._loadColour(confParser,cnfSec,"singlequotes")
self.colComm = self._loadColour(confParser,cnfSec,"hidden")
self.colKey = self._loadColour(confParser,cnfSec,"keyword")
self.colVal = self._loadColour(confParser,cnfSec,"value")
self.colSpell = self._loadColour(confParser,cnfSec,"spellcheckline")
self.colTagErr = self._loadColour(confParser,cnfSec,"tagerror")
self.colRepTag = self._loadColour(confParser,cnfSec,"replacetag")
self.colBack = self._loadColour(confParser, cnfSec, "background")
self.colText = self._loadColour(confParser, cnfSec, "text")
self.colLink = self._loadColour(confParser, cnfSec, "link")
self.colHead = self._loadColour(confParser, cnfSec, "headertext")
self.colHeadH = self._loadColour(confParser, cnfSec, "headertag")
self.colEmph = self._loadColour(confParser, cnfSec, "emphasis")
self.colDialN = self._loadColour(confParser, cnfSec, "straightquotes")
self.colDialD = self._loadColour(confParser, cnfSec, "doublequotes")
self.colDialS = self._loadColour(confParser, cnfSec, "singlequotes")
self.colComm = self._loadColour(confParser, cnfSec, "hidden")
self.colKey = self._loadColour(confParser, cnfSec, "keyword")
self.colVal = self._loadColour(confParser, cnfSec, "value")
self.colSpell = self._loadColour(confParser, cnfSec, "spellcheckline")
self.colTagErr = self._loadColour(confParser, cnfSec, "tagerror")
self.colRepTag = self._loadColour(confParser, cnfSec, "replacetag")
logger.info("Loaded syntax theme '%s'" % self.guiSyntax)
@@ -251,7 +251,7 @@ class Theme:
themeConf = path.join(self.mainConf.themeRoot, self.guiPath, themeDir, self.confName)
logger.verbose("Checking theme config for '%s'" % themeDir)
try:
confParser.read_file(open(themeConf,mode="r",encoding="utf8"))
confParser.read_file(open(themeConf, mode="r", encoding="utf8"))
except Exception as e:
self.theParent.makeAlert(["Could not load theme config file",str(e)],nwAlert.ERROR)
continue
@@ -279,7 +279,7 @@ class Theme:
continue
logger.verbose("Checking theme syntax for '%s'" % syntaxFile)
try:
confParser.read_file(open(syntaxPath,mode="r",encoding="utf8"))
confParser.read_file(open(syntaxPath, mode="r", encoding="utf8"))
except Exception as e:
self.theParent.makeAlert(["Could not load syntax file",str(e)],nwAlert.ERROR)
return []