diff --git a/nw/config.py b/nw/config.py index 30d65cdf..a47e7c24 100644 --- a/nw/config.py +++ b/nw/config.py @@ -200,65 +200,133 @@ class Config: logger.debug("Loading config file") cnfParse = configparser.ConfigParser() try: - cnfParse.read_file(open(path.join(self.confPath,self.confFile),mode="r",encoding="utf8")) + cnfParse.read_file( + open(path.join(self.confPath,self.confFile),mode="r",encoding="utf8") + ) except Exception as e: logger.error("Could not load config file") return False ## Main cnfSec = "Main" - self.guiTheme = self._parseLine(cnfParse, cnfSec, "theme", self.CNF_STR, self.guiTheme) - self.guiSyntax = self._parseLine(cnfParse, cnfSec, "syntax", self.CNF_STR, self.guiSyntax) + self.guiTheme = self._parseLine( + cnfParse, cnfSec, "theme", self.CNF_STR, self.guiTheme + ) + self.guiSyntax = self._parseLine( + cnfParse, cnfSec, "syntax", self.CNF_STR, self.guiSyntax + ) ## Sizes cnfSec = "Sizes" - self.winGeometry = self._parseLine(cnfParse, cnfSec, "geometry", self.CNF_LIST, self.winGeometry) - self.treeColWidth = self._parseLine(cnfParse, cnfSec, "treecols", self.CNF_LIST, self.treeColWidth) - self.mainPanePos = self._parseLine(cnfParse, cnfSec, "mainpane", self.CNF_LIST, self.mainPanePos) - self.docPanePos = self._parseLine(cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos) + self.winGeometry = self._parseLine( + cnfParse, cnfSec, "geometry", self.CNF_LIST, self.winGeometry + ) + self.treeColWidth = self._parseLine( + cnfParse, cnfSec, "treecols", self.CNF_LIST, self.treeColWidth + ) + self.mainPanePos = self._parseLine( + cnfParse, cnfSec, "mainpane", self.CNF_LIST, self.mainPanePos + ) + self.docPanePos = self._parseLine( + cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos + ) ## Project cnfSec = "Project" - self.autoSaveProj = self._parseLine(cnfParse, cnfSec, "autosaveproject", self.CNF_INT, self.autoSaveProj) - self.autoSaveDoc = self._parseLine(cnfParse, cnfSec, "autosavedoc", self.CNF_INT, self.autoSaveDoc) + self.autoSaveProj = self._parseLine( + cnfParse, cnfSec, "autosaveproject", self.CNF_INT, self.autoSaveProj + ) + self.autoSaveDoc = self._parseLine( + cnfParse, cnfSec, "autosavedoc", self.CNF_INT, self.autoSaveDoc + ) ## Editor cnfSec = "Editor" - self.textFont = self._parseLine(cnfParse, cnfSec, "textfont", self.CNF_STR, self.textFont) - self.textSize = self._parseLine(cnfParse, cnfSec, "textsize", self.CNF_INT, self.textSize) - self.textFixedW = self._parseLine(cnfParse, cnfSec, "fixedwidth", self.CNF_BOOL, self.textFixedW) - self.textWidth = self._parseLine(cnfParse, cnfSec, "width", self.CNF_INT, self.textWidth) - self.textMargin = self._parseLine(cnfParse, cnfSec, "margin", self.CNF_INT, self.textMargin) - self.tabWidth = self._parseLine(cnfParse, cnfSec, "tabwidth", self.CNF_INT, self.tabWidth) - self.doJustify = self._parseLine(cnfParse, cnfSec, "justify", self.CNF_BOOL, self.doJustify) - self.autoSelect = self._parseLine(cnfParse, cnfSec, "autoselect", self.CNF_BOOL, self.autoSelect) - self.doReplace = self._parseLine(cnfParse, cnfSec, "autoreplace", self.CNF_BOOL, self.doReplace) - self.doReplaceSQuote = self._parseLine(cnfParse, cnfSec, "repsquotes", self.CNF_BOOL, self.doReplaceSQuote) - self.doReplaceDQuote = self._parseLine(cnfParse, cnfSec, "repdquotes", self.CNF_BOOL, self.doReplaceDQuote) - self.doReplaceDash = self._parseLine(cnfParse, cnfSec, "repdash", self.CNF_BOOL, self.doReplaceDash) - self.doReplaceDots = self._parseLine(cnfParse, cnfSec, "repdots", self.CNF_BOOL, self.doReplaceDots) - self.fmtSingleQuotes = self._parseLine(cnfParse, cnfSec, "fmtsinglequote", self.CNF_LIST, self.fmtSingleQuotes) - self.fmtDoubleQuotes = self._parseLine(cnfParse, cnfSec, "fmtdoublequote", self.CNF_LIST, self.fmtDoubleQuotes) - self.spellLanguage = self._parseLine(cnfParse, cnfSec, "spellcheck", self.CNF_STR, self.spellLanguage) - self.showTabsNSpaces = self._parseLine(cnfParse, cnfSec, "showtabsnspaces", self.CNF_BOOL, self.showTabsNSpaces) - self.showLineEndings = self._parseLine(cnfParse, cnfSec, "showlineendings", self.CNF_BOOL, self.showLineEndings) + self.textFont = self._parseLine( + cnfParse, cnfSec, "textfont", self.CNF_STR, self.textFont + ) + self.textSize = self._parseLine( + cnfParse, cnfSec, "textsize", self.CNF_INT, self.textSize + ) + self.textFixedW = self._parseLine( + cnfParse, cnfSec, "fixedwidth", self.CNF_BOOL, self.textFixedW + ) + self.textWidth = self._parseLine( + cnfParse, cnfSec, "width", self.CNF_INT, self.textWidth + ) + self.textMargin = self._parseLine( + cnfParse, cnfSec, "margin", self.CNF_INT, self.textMargin + ) + self.tabWidth = self._parseLine( + cnfParse, cnfSec, "tabwidth", self.CNF_INT, self.tabWidth + ) + self.doJustify = self._parseLine( + cnfParse, cnfSec, "justify", self.CNF_BOOL, self.doJustify + ) + self.autoSelect = self._parseLine( + cnfParse, cnfSec, "autoselect", self.CNF_BOOL, self.autoSelect + ) + self.doReplace = self._parseLine( + cnfParse, cnfSec, "autoreplace", self.CNF_BOOL, self.doReplace + ) + self.doReplaceSQuote = self._parseLine( + cnfParse, cnfSec, "repsquotes", self.CNF_BOOL, self.doReplaceSQuote + ) + self.doReplaceDQuote = self._parseLine( + cnfParse, cnfSec, "repdquotes", self.CNF_BOOL, self.doReplaceDQuote + ) + self.doReplaceDash = self._parseLine( + cnfParse, cnfSec, "repdash", self.CNF_BOOL, self.doReplaceDash + ) + self.doReplaceDots = self._parseLine( + cnfParse, cnfSec, "repdots", self.CNF_BOOL, self.doReplaceDots + ) + self.fmtSingleQuotes = self._parseLine( + cnfParse, cnfSec, "fmtsinglequote", self.CNF_LIST, self.fmtSingleQuotes + ) + self.fmtDoubleQuotes = self._parseLine( + cnfParse, cnfSec, "fmtdoublequote", self.CNF_LIST, self.fmtDoubleQuotes + ) + self.spellLanguage = self._parseLine( + cnfParse, cnfSec, "spellcheck", self.CNF_STR, self.spellLanguage + ) + self.showTabsNSpaces = self._parseLine( + cnfParse, cnfSec, "showtabsnspaces", self.CNF_BOOL, self.showTabsNSpaces + ) + self.showLineEndings = self._parseLine( + cnfParse, cnfSec, "showlineendings", self.CNF_BOOL, self.showLineEndings + ) ## Backup cnfSec = "Backup" - self.backupPath = self._parseLine(cnfParse, cnfSec, "backuppath", self.CNF_STR, self.backupPath) - self.backupOnClose = self._parseLine(cnfParse, cnfSec, "backuponclose", self.CNF_BOOL, self.backupOnClose) - self.askBeforeBackup = self._parseLine(cnfParse, cnfSec, "askbeforebackup", self.CNF_BOOL, self.askBeforeBackup) + self.backupPath = self._parseLine( + cnfParse, cnfSec, "backuppath", self.CNF_STR, self.backupPath + ) + self.backupOnClose = self._parseLine( + cnfParse, cnfSec, "backuponclose", self.CNF_BOOL, self.backupOnClose + ) + self.askBeforeBackup = self._parseLine( + cnfParse, cnfSec, "askbeforebackup", self.CNF_BOOL, self.askBeforeBackup + ) ## State cnfSec = "State" - self.showRefPanel = self._parseLine(cnfParse, cnfSec, "showrefpanel", self.CNF_BOOL, self.showRefPanel) - self.viewComments = self._parseLine(cnfParse, cnfSec, "viewcomments", self.CNF_BOOL, self.viewComments) + self.showRefPanel = self._parseLine( + cnfParse, cnfSec, "showrefpanel", self.CNF_BOOL, self.showRefPanel + ) + self.viewComments = self._parseLine( + cnfParse, cnfSec, "viewcomments", self.CNF_BOOL, self.viewComments + ) ## Path cnfSec = "Path" - self.lastPath = self._parseLine(cnfParse, cnfSec, "lastpath", self.CNF_STR, self.lastPath) + self.lastPath = self._parseLine( + cnfParse, cnfSec, "lastpath", self.CNF_STR, self.lastPath + ) for i in range(10): - self.recentList[i] = self._parseLine(cnfParse, cnfSec, "recent%d" % i,self.CNF_STR, self.recentList[i]) + self.recentList[i] = self._parseLine( + cnfParse, cnfSec, "recent%d" % i,self.CNF_STR, self.recentList[i] + ) # Check Certain Values for None self.spellLanguage = self._checkNone(self.spellLanguage) diff --git a/nw/convert/text/tomarkdown.py b/nw/convert/text/tomarkdown.py index bd422836..78098c5e 100644 --- a/nw/convert/text/tomarkdown.py +++ b/nw/convert/text/tomarkdown.py @@ -71,7 +71,9 @@ class ToMarkdown(Tokenizer): # The text can now be word wrapped, if we have requested this and it's needed. if self.wordWrap > 0 and tLen > self.wordWrap: if tType == self.T_COMMENT: - tText = textwrap.fill(tText.strip(),initial_indent=" ",subsequent_indent=" ") + tText = textwrap.fill( + tText.strip(),initial_indent=" ",subsequent_indent=" " + ) else: tText = tWrap.fill(tText) diff --git a/nw/convert/tokenizer.py b/nw/convert/tokenizer.py index 55452915..acc90b91 100644 --- a/nw/convert/tokenizer.py +++ b/nw/convert/tokenizer.py @@ -203,7 +203,8 @@ class Tokenizer(): xLen = rxMatch.capturedLength(n) fmtPos.append([xPos,xLen,theKeys[n]]) - # Save the line as is, but append the array of formatting locations sorted by position + # Save the line as is, but append the array of formatting locations + # sorted by position fmtPos = sorted(fmtPos,key=itemgetter(0)) self.theTokens.append((self.T_TEXT,aLine,fmtPos,self.A_LEFT)) diff --git a/nw/gui/dialogs/configeditor.py b/nw/gui/dialogs/configeditor.py index a77dcfc8..fd90ec9a 100644 --- a/nw/gui/dialogs/configeditor.py +++ b/nw/gui/dialogs/configeditor.py @@ -407,7 +407,9 @@ class GuiConfigEditEditor(QWidget): self.autoReplaceDQ.setCheckState(Qt.Unchecked) self.autoReplaceDash = QCheckBox(self) - self.autoReplaceDash.setToolTip("Auto-replace double and triple hyphens with short and long dash.") + self.autoReplaceDash.setToolTip( + "Auto-replace double and triple hyphens with short and long dash." + ) if self.mainConf.doReplaceDash: self.autoReplaceDash.setCheckState(Qt.Checked) else: diff --git a/nw/gui/dialogs/export.py b/nw/gui/dialogs/export.py index d9f3b7e9..d3be1260 100644 --- a/nw/gui/dialogs/export.py +++ b/nw/gui/dialogs/export.py @@ -510,7 +510,9 @@ class GuiExportMain(QWidget): self.fixedWidth.setMaximum(999) self.fixedWidth.setSingleStep(1) self.fixedWidth.setValue(self.optState.getSetting("fixWidth")) - self.fixedWidth.setToolTip("Applies to .txt and .md files. A value of '0' disables the feature.") + self.fixedWidth.setToolTip( + "Applies to .txt and .md files. A value of '0' disables the feature." + ) self.addSettingsForm.addWidget(QLabel("Fixed width"), 0, 0) self.addSettingsForm.addWidget(self.fixedWidth, 0, 1) diff --git a/nw/gui/dialogs/itemeditor.py b/nw/gui/dialogs/itemeditor.py index d5ae459d..a5bc5fe1 100644 --- a/nw/gui/dialogs/itemeditor.py +++ b/nw/gui/dialogs/itemeditor.py @@ -13,14 +13,16 @@ import logging import nw -from os import path +from os import path from PyQt5.QtCore import Qt, QSize -from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox from PyQt5.QtSvg import QSvgWidget +from PyQt5.QtWidgets import ( + QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox +) -from nw.enum import nwItemLayout, nwItemClass, nwItemType -from nw.constants import nwLabels +from nw.enum import nwItemLayout, nwItemClass, nwItemType +from nw.constants import nwLabels logger = logging.getLogger(__name__) @@ -36,8 +38,8 @@ class GuiItemEditor(QDialog): self.theParent = theParent self.theItem = self.theProject.getItem(tHandle) - self.outerBox = QHBoxLayout() - self.innerBox = QVBoxLayout() + self.outerBox = QHBoxLayout() + self.innerBox = QVBoxLayout() self.setWindowTitle("Item Settings") diff --git a/nw/gui/dialogs/projecteditor.py b/nw/gui/dialogs/projecteditor.py index bd42cdb5..4909d835 100644 --- a/nw/gui/dialogs/projecteditor.py +++ b/nw/gui/dialogs/projecteditor.py @@ -221,7 +221,9 @@ class GuiProjectEditStatus(QWidget): def _selectColour(self): logger.verbose("Item colour button clicked") if self.selColour is not None: - newCol = QColorDialog.getColor(self.selColour, self, "Select Colour", QColorDialog.DontUseNativeDialog) + newCol = QColorDialog.getColor( + self.selColour, self, "Select Colour", QColorDialog.DontUseNativeDialog + ) if newCol: self.selColour = newCol colPixmap = QPixmap(16,16) diff --git a/nw/gui/dialogs/sessionlog.py b/nw/gui/dialogs/sessionlog.py index 3c400acf..be2a1f94 100644 --- a/nw/gui/dialogs/sessionlog.py +++ b/nw/gui/dialogs/sessionlog.py @@ -70,8 +70,12 @@ class GuiSessionLogView(QDialog): self.monoFont = QFont("Monospace",10) sortValid = (Qt.AscendingOrder, Qt.DescendingOrder) - sortCol = self.optState.validIntRange(self.optState.getSetting("sortCol"), 0, 2, 0) - sortOrder = self.optState.validIntTuple(self.optState.getSetting("sortOrder"), sortValid, Qt.DescendingOrder) + sortCol = self.optState.validIntRange( + self.optState.getSetting("sortCol"), 0, 2, 0 + ) + sortOrder = self.optState.validIntTuple( + self.optState.getSetting("sortOrder"), sortValid, Qt.DescendingOrder + ) self.listBox.sortByColumn(sortCol, sortOrder) self.listBox.setSortingEnabled(True) diff --git a/nw/gui/dialogs/timelineview.py b/nw/gui/dialogs/timelineview.py index fba390ea..fb0a00d5 100644 --- a/nw/gui/dialogs/timelineview.py +++ b/nw/gui/dialogs/timelineview.py @@ -13,7 +13,8 @@ import logging import nw -from os import path +from os import path + from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon, QColor, QPixmap from PyQt5.QtWidgets import ( @@ -41,21 +42,25 @@ class GuiTimeLineView(QDialog): self.optState = TimeLineLastState(self.theProject,nwFiles.TLINE_OPT) self.optState.loadSettings() - self.theMatrix = {} - self.numRows = 0 - self.numCols = 0 + self.theMatrix = {} + self.numRows = 0 + self.numCols = 0 - self.outerBox = QVBoxLayout() - self.filterBox = QVBoxLayout() - self.centreBox = QHBoxLayout() - self.bottomBox = QHBoxLayout() + self.outerBox = QVBoxLayout() + self.filterBox = QVBoxLayout() + self.centreBox = QHBoxLayout() + self.bottomBox = QHBoxLayout() self.setWindowTitle("Timeline View") self.setMinimumWidth(700) self.setMinimumHeight(400) - winWidth = self.optState.validIntRange(self.optState.getSetting("winWidth"), 700, 10000, 700) - winHeight = self.optState.validIntRange(self.optState.getSetting("winHeight"), 400, 10000, 400) + winWidth = self.optState.validIntRange( + self.optState.getSetting("winWidth"), 700, 10000, 700 + ) + winHeight = self.optState.validIntRange( + self.optState.getSetting("winHeight"), 400, 10000, 400 + ) self.resize(winWidth,winHeight) # TimeLine Table diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 852d3272..e2214b03 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -82,9 +82,24 @@ class GuiDocEditor(QTextEdit): self.setAcceptRichText(False) # Custom Shortcuts - QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext) - QShortcut(Qt.Key_Return | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._followTag) - QShortcut(Qt.Key_Enter | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._followTag) + QShortcut( + QKeySequence("Ctrl+."), + self, + context = Qt.WidgetShortcut, + activated = self._openSpellContext + ) + QShortcut( + Qt.Key_Return | Qt.ControlModifier, + self, + context = Qt.WidgetShortcut, + activated = self._followTag + ) + QShortcut( + Qt.Key_Enter | Qt.ControlModifier, + self, + context = Qt.WidgetShortcut, + activated = self._followTag + ) # Set Up Word Count Thread and Timer self.wcInterval = self.mainConf.wordCountTimer @@ -459,7 +474,9 @@ class GuiDocEditor(QTextEdit): if len(theSuggest) > 0: for aWord in theSuggest: mnuWord = QAction(aWord, mnuSuggest) - mnuWord.triggered.connect(lambda thePos, aWord=aWord : self._correctWord(theCursor, aWord)) + mnuWord.triggered.connect( + lambda thePos, aWord=aWord : self._correctWord(theCursor, aWord) + ) mnuSuggest.addAction(mnuWord) mnuSuggest.addSeparator() mnuAdd = QAction("Add Word to Dictionary", mnuSuggest) diff --git a/nw/gui/elements/doctree.py b/nw/gui/elements/doctree.py index 9b4bc750..854ceac4 100644 --- a/nw/gui/elements/doctree.py +++ b/nw/gui/elements/doctree.py @@ -18,8 +18,8 @@ from PyQt5.QtGui import QIcon, QFont, QColor from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication from nw.project.item import NWItem -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert from nw.constants import nwLabels +from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert logger = logging.getLogger(__name__) @@ -145,11 +145,15 @@ class GuiDocTree(QTreeWidget): # If we again has no home, give up if pHandle is None: - self.makeAlert("Did not find anywhere to add the file or folder!", nwAlert.ERROR) + self.makeAlert( + "Did not find anywhere to add the file or folder!", nwAlert.ERROR + ) return False if pHandle == self.theProject.trashRoot: - self.makeAlert("Cannot add new files or folders to the trash folder.", nwAlert.ERROR) + self.makeAlert( + "Cannot add new files or folders to the trash folder.", nwAlert.ERROR + ) return False # If we're still here, add the file or folder @@ -295,10 +299,10 @@ class GuiDocTree(QTreeWidget): tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout] iStatus = nwItem.itemStatus if tClass == nwItemClass.NOVEL: - iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's a valid index + iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid flagIcon = self.theParent.statusIcons[iStatus] else: - iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's a valid index + iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid flagIcon = self.theParent.importIcons[iStatus] trItem.setText(self.C_NAME, tName) diff --git a/nw/gui/elements/docviewer.py b/nw/gui/elements/docviewer.py index 468f4f2b..9edd1838 100644 --- a/nw/gui/elements/docviewer.py +++ b/nw/gui/elements/docviewer.py @@ -205,24 +205,24 @@ class GuiDocViewer(QTextBrowser): ).format( textSize = self.mainConf.textSize, preSize = self.mainConf.textSize*0.9, - tColR = self.theTheme.colText[0], - tColG = self.theTheme.colText[1], - tColB = self.theTheme.colText[2], - hColR = self.theTheme.colHead[0], - hColG = self.theTheme.colHead[1], - hColB = self.theTheme.colHead[2], - cColR = self.theTheme.colComm[0], - cColG = self.theTheme.colComm[1], - cColB = self.theTheme.colComm[2], - eColR = self.theTheme.colEmph[0], - eColG = self.theTheme.colEmph[1], - eColB = self.theTheme.colEmph[2], - aColR = self.theTheme.colVal[0], - aColG = self.theTheme.colVal[1], - aColB = self.theTheme.colVal[2], - kColR = self.theTheme.colKey[0], - kColG = self.theTheme.colKey[1], - kColB = self.theTheme.colKey[2], + tColR = self.theTheme.colText[0], + tColG = self.theTheme.colText[1], + tColB = self.theTheme.colText[2], + hColR = self.theTheme.colHead[0], + hColG = self.theTheme.colHead[1], + hColB = self.theTheme.colHead[2], + cColR = self.theTheme.colComm[0], + cColG = self.theTheme.colComm[1], + cColB = self.theTheme.colComm[2], + eColR = self.theTheme.colEmph[0], + eColG = self.theTheme.colEmph[1], + eColB = self.theTheme.colEmph[2], + aColR = self.theTheme.colVal[0], + aColG = self.theTheme.colVal[1], + aColB = self.theTheme.colVal[2], + kColR = self.theTheme.colKey[0], + kColG = self.theTheme.colKey[1], + kColB = self.theTheme.colKey[2], ) self.qDocument.setDefaultStyleSheet(styleSheet) diff --git a/nw/gui/elements/searchbar.py b/nw/gui/elements/searchbar.py index e5da35ee..8fab6e93 100644 --- a/nw/gui/elements/searchbar.py +++ b/nw/gui/elements/searchbar.py @@ -17,7 +17,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication -from nw.enum import nwDocAction +from nw.enum import nwDocAction logger = logging.getLogger(__name__) diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index e40975ae..49551b9b 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -353,7 +353,9 @@ class GuiMainMenu(QMenuBar): # Document > Show File Details menuItem = QAction("Show File Details", self) - menuItem.setStatusTip("Shows a message box with the document location in the project folder") + menuItem.setStatusTip( + "Shows a message box with the document location in the project folder" + ) menuItem.triggered.connect(self._showDocumentLocation) self.docuMenu.addAction(menuItem) diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index c64c095d..a6bf6f01 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -63,10 +63,18 @@ class GuiMain(QMainWindow): self.theIndex = NWIndex(self.theProject, self) self.hasProject = False - logger.info("OS: %s" % (self.mainConf.osType)) - 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("Python Version: %s (0x%x)" % (self.mainConf.verPyString, self.mainConf.verPyHexVal)) + logger.info("OS: %s" % ( + self.mainConf.osType) + ) + 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("Python Version: %s (0x%x)" % ( + self.mainConf.verPyString, self.mainConf.verPyHexVal) + ) self.resize(*self.mainConf.winGeometry) self._setWindowTitle() @@ -157,8 +165,17 @@ class GuiMain(QMainWindow): self.asDocTimer.timeout.connect(self._autoSaveDocument) # Keyboard Shortcuts - QShortcut(Qt.Key_Return, self.treeView, context=Qt.WidgetShortcut, activated=self._treeKeyPressReturn) - QShortcut(Qt.Key_Escape, self, activated=self._keyPressEscape) + QShortcut( + Qt.Key_Return, + self.treeView, + context = Qt.WidgetShortcut, + activated = self._treeKeyPressReturn + ) + QShortcut( + Qt.Key_Escape, + self, + activated = self._keyPressEscape + ) # Forward Functions self.setStatus = self.statusBar.setStatus @@ -271,8 +288,8 @@ class GuiMain(QMainWindow): return saveOK def openProject(self, projFile=None): - """Open a project. - projFile is passed from the open recent projects menu, so can be set. If not, we pop the dialog. + """Open a project. The parameter projFile is passed from the open recent projects menu, so + can be set. If not, we pop the dialog. """ if projFile is None: projFile = self.openProjectDialog() @@ -415,20 +432,26 @@ class GuiMain(QMainWindow): with open(loadFile,mode="rt",encoding="utf8") as inFile: theText = inFile.read() except Exception as e: - self.makeAlert(["Could not read file. The file cannot be a binary file.",str(e)], nwAlert.ERROR) + self.makeAlert( + ["Could not read file. The file cannot be a binary file.",str(e)], + nwAlert.ERROR + ) return False if self.docEditor.theHandle is None: - self.makeAlert(["Please open a document to import the text file into."], nwAlert.ERROR) + self.makeAlert( + ["Please open a document to import the text file into."], + nwAlert.ERROR + ) return False if not self.docEditor.isEmpty(): if self.mainConf.showGUI: msgBox = QMessageBox() - msgRes = msgBox.question( - self, "Import Document", - "Importing the file will overwrite the current content of the document. Do you want to proceed?" - ) + msgRes = msgBox.question(self, "Import Document",( + "Importing the file will overwrite the current content of the document. " + "Do you want to proceed?" + )) if msgRes != QMessageBox.Yes: return False else: @@ -733,7 +756,8 @@ class GuiMain(QMainWindow): ## def resizeEvent(self, theEvent): - """Extend QMainWindow.resizeEvent to signal dependent GUI elements that its pane may have changed size. + """Extend QMainWindow.resizeEvent to signal dependent GUI elements that its pane may have + changed size. """ QMainWindow.resizeEvent(self,theEvent) self.docEditor.changeWidth() @@ -779,7 +803,7 @@ class GuiMain(QMainWindow): return def _keyPressEscape(self): - """When the escape key is pressed somewhere in the main window, do the following, in order + """When the escape key is pressed somewhere in the main window, do the following, in order. """ if self.searchBar.isVisible(): self.searchBar.setVisible(False) diff --git a/nw/project/backup.py b/nw/project/backup.py index bb69309a..993c4406 100644 --- a/nw/project/backup.py +++ b/nw/project/backup.py @@ -32,11 +32,15 @@ class NWBackup(): def zipIt(self): if self.mainConf.backupPath is None: - self.theParent.makeAlert("Cannot backup project because no backup path is set.",nwAlert.WARN) + self.theParent.makeAlert( + "Cannot backup project because no backup path is set.",nwAlert.WARN + ) return False if self.theProject.projName is None: - self.theParent.makeAlert("Cannot backup project because no project name is set.",nwAlert.WARN) + self.theParent.makeAlert( + "Cannot backup project because no project name is set.",nwAlert.WARN + ) return False logger.info("Backing up project") @@ -55,7 +59,10 @@ class NWBackup(): try: make_archive(baseName, "zip", self.theProject.projPath, ".") except Exception as e: - self.theParent.makeAlert(["Could not write backup archive.",str(e)],nwAlert.ERROR) + self.theParent.makeAlert( + ["Could not write backup archive.",str(e)], + nwAlert.ERROR + ) return False self.theParent.statusBar.setStatus("Project backup complete") diff --git a/nw/project/project.py b/nw/project/project.py index aa9bc9d2..9a0bfd03 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -214,7 +214,10 @@ class NWProject(): logger.verbose("File version is %s" % fileVersion) if not nwxRoot == "novelWriterXML" or not fileVersion == "1.0": - self.makeAlert("Project file does not appear to be a novelWriterXML file version 1.0", nwAlert.ERROR) + self.makeAlert( + "Project file does not appear to be a novelWriterXML file version 1.0", + nwAlert.ERROR + ) return False for xChild in xRoot: @@ -399,16 +402,16 @@ class NWProject(): self.doBackup = False if doBackup: if not path.isdir(self.mainConf.backupPath): - self.theParent.makeAlert( - "You must set a valid backup path in preferences
to use the automatic project backup feature.", - nwAlert.ERROR - ) + self.theParent.makeAlert(( + "You must set a valid backup path in preferences to use " + "the automatic project backup feature." + ), nwAlert.ERROR) 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.", - nwAlert.ERROR - ) + self.theParent.makeAlert(( + "You must set a valid project name in project settings to use " + "the automatic project backup feature." + ), nwAlert.ERROR) return False self.doBackup = True return True @@ -634,7 +637,10 @@ class NWProject(): # Report status if len(orphanFiles) > 0: - self.makeAlert("Found %d orphaned file(s) in project folder!" % len(orphanFiles), nwAlert.WARN) + self.makeAlert( + "Found %d orphaned file(s) in project folder!" % len(orphanFiles), + nwAlert.WARN + ) else: logger.debug("File check OK") return