Further PEP8 compliance changes
This commit is contained in:
+12
-6
@@ -17,16 +17,20 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def checkString(checkValue, defaultValue, allowNone=False):
|
def checkString(checkValue, defaultValue, allowNone=False):
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None: return None
|
if checkValue == None:
|
||||||
if checkValue == "None": return None
|
return None
|
||||||
|
if checkValue == "None":
|
||||||
|
return None
|
||||||
if isinstance(checkValue,str):
|
if isinstance(checkValue,str):
|
||||||
return str(checkValue)
|
return str(checkValue)
|
||||||
return defaultValue
|
return defaultValue
|
||||||
|
|
||||||
def checkInt(checkValue, defaultValue, allowNone=False):
|
def checkInt(checkValue, defaultValue, allowNone=False):
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None: return None
|
if checkValue == None:
|
||||||
if checkValue == "None": return None
|
return None
|
||||||
|
if checkValue == "None":
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return int(checkValue)
|
return int(checkValue)
|
||||||
except:
|
except:
|
||||||
@@ -34,8 +38,10 @@ def checkInt(checkValue, defaultValue, allowNone=False):
|
|||||||
|
|
||||||
def checkBool(checkValue, defaultValue, allowNone=False):
|
def checkBool(checkValue, defaultValue, allowNone=False):
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None: return None
|
if checkValue == None:
|
||||||
if checkValue == "None": return None
|
return None
|
||||||
|
if checkValue == "None":
|
||||||
|
return None
|
||||||
if isinstance(checkValue, str):
|
if isinstance(checkValue, str):
|
||||||
if checkValue == "True":
|
if checkValue == "True":
|
||||||
return True
|
return True
|
||||||
|
|||||||
+3
-3
@@ -19,12 +19,12 @@ from os import path, mkdir, makedirs, getcwd
|
|||||||
from appdirs import user_config_dir
|
from appdirs import user_config_dir
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from nw.constants import nwFiles, nwUnicode
|
|
||||||
from nw.common import splitVersionNumber
|
|
||||||
|
|
||||||
from PyQt5.Qt import PYQT_VERSION_STR
|
from PyQt5.Qt import PYQT_VERSION_STR
|
||||||
from PyQt5.QtCore import QT_VERSION_STR
|
from PyQt5.QtCore import QT_VERSION_STR
|
||||||
|
|
||||||
|
from nw.constants import nwFiles, nwUnicode
|
||||||
|
from nw.common import splitVersionNumber
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import logging
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
|
|
||||||
from nw.convert.file.text import TextFile
|
from nw.convert.file.text import TextFile
|
||||||
@@ -26,9 +27,7 @@ class ConcatFile(TextFile):
|
|||||||
|
|
||||||
def __init__(self, theProject, theParent):
|
def __init__(self, theProject, theParent):
|
||||||
TextFile.__init__(self, theProject, theParent)
|
TextFile.__init__(self, theProject, theParent)
|
||||||
|
|
||||||
self.theConv = Tokenizer(self.theProject, self.theParent)
|
self.theConv = Tokenizer(self.theProject, self.theParent)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def addText(self, tHandle):
|
def addText(self, tHandle):
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ class HtmlFile(TextFile):
|
|||||||
|
|
||||||
def __init__(self, theProject, theParent):
|
def __init__(self, theProject, theParent):
|
||||||
TextFile.__init__(self, theProject, theParent)
|
TextFile.__init__(self, theProject, theParent)
|
||||||
|
|
||||||
self.theConv = ToHtml(self.theProject, self.theParent)
|
self.theConv = ToHtml(self.theProject, self.theParent)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class LaTeXFile(TextFile):
|
|||||||
##
|
##
|
||||||
|
|
||||||
def _doOpenFile(self, filePath):
|
def _doOpenFile(self, filePath):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="wt+",encoding="utf8")
|
self.outFile = open(filePath,mode="wt+",encoding="utf8")
|
||||||
self.outFile.write("\\documentclass[12pt]{report}\n")
|
self.outFile.write("\\documentclass[12pt]{report}\n")
|
||||||
@@ -43,17 +42,13 @@ class LaTeXFile(TextFile):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _doCloseFile(self):
|
def _doCloseFile(self):
|
||||||
|
|
||||||
if self.outFile is not None:
|
if self.outFile is not None:
|
||||||
self.outFile.write("\\end{document}\n")
|
self.outFile.write("\\end{document}\n")
|
||||||
self.outFile.close()
|
self.outFile.close()
|
||||||
|
|
||||||
self.texCodecFail = self.theConv.texCodecFail
|
self.texCodecFail = self.theConv.texCodecFail
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# END Class LaTeXFile
|
# END Class LaTeXFile
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ class MarkdownFile(TextFile):
|
|||||||
|
|
||||||
def __init__(self, theProject, theParent):
|
def __init__(self, theProject, theParent):
|
||||||
TextFile.__init__(self, theProject, theParent)
|
TextFile.__init__(self, theProject, theParent)
|
||||||
|
|
||||||
self.theConv = ToMarkdown(self.theProject, self.theParent)
|
self.theConv = ToMarkdown(self.theProject, self.theParent)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import logging
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
|
|
||||||
from nw.convert.text.totext import ToText
|
from nw.convert.text.totext import ToText
|
||||||
|
|||||||
@@ -31,12 +31,10 @@ class ToHtml(Tokenizer):
|
|||||||
need to make a few changes to formatting, which is selected by
|
need to make a few changes to formatting, which is selected by
|
||||||
this flag.
|
this flag.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.forPreview = forPreview
|
self.forPreview = forPreview
|
||||||
if forPreview:
|
if forPreview:
|
||||||
self.doKeywords = True
|
self.doKeywords = True
|
||||||
self.doComments = doComments
|
self.doComments = doComments
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def doAutoReplace(self):
|
def doAutoReplace(self):
|
||||||
|
|||||||
@@ -230,7 +230,8 @@ class Tokenizer():
|
|||||||
if isNone: return
|
if isNone: return
|
||||||
if isNote: 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:
|
if isBook or isUnNum or isChap or isScene:
|
||||||
for n in range(len(self.theTokens)):
|
for n in range(len(self.theTokens)):
|
||||||
|
|
||||||
|
|||||||
@@ -557,25 +557,33 @@ class GuiConfigEditEditor(QWidget):
|
|||||||
if self._checkQuoteSymbol(fmtSingleQuotesO):
|
if self._checkQuoteSymbol(fmtSingleQuotesO):
|
||||||
self.mainConf.fmtSingleQuotes[0] = fmtSingleQuotesO
|
self.mainConf.fmtSingleQuotes[0] = fmtSingleQuotesO
|
||||||
else:
|
else:
|
||||||
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtSingleQuotesO, nwAlert.ERROR)
|
self.theParent.makeAlert(
|
||||||
|
"Invalid quote symbol: %s" % fmtSingleQuotesO, nwAlert.ERROR
|
||||||
|
)
|
||||||
validEntries = False
|
validEntries = False
|
||||||
|
|
||||||
if self._checkQuoteSymbol(fmtSingleQuotesC):
|
if self._checkQuoteSymbol(fmtSingleQuotesC):
|
||||||
self.mainConf.fmtSingleQuotes[1] = fmtSingleQuotesC
|
self.mainConf.fmtSingleQuotes[1] = fmtSingleQuotesC
|
||||||
else:
|
else:
|
||||||
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtSingleQuotesC, nwAlert.ERROR)
|
self.theParent.makeAlert(
|
||||||
|
"Invalid quote symbol: %s" % fmtSingleQuotesC, nwAlert.ERROR
|
||||||
|
)
|
||||||
validEntries = False
|
validEntries = False
|
||||||
|
|
||||||
if self._checkQuoteSymbol(fmtDoubleQuotesO):
|
if self._checkQuoteSymbol(fmtDoubleQuotesO):
|
||||||
self.mainConf.fmtDoubleQuotes[0] = fmtDoubleQuotesO
|
self.mainConf.fmtDoubleQuotes[0] = fmtDoubleQuotesO
|
||||||
else:
|
else:
|
||||||
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtDoubleQuotesO, nwAlert.ERROR)
|
self.theParent.makeAlert(
|
||||||
|
"Invalid quote symbol: %s" % fmtDoubleQuotesO, nwAlert.ERROR
|
||||||
|
)
|
||||||
validEntries = False
|
validEntries = False
|
||||||
|
|
||||||
if self._checkQuoteSymbol(fmtDoubleQuotesC):
|
if self._checkQuoteSymbol(fmtDoubleQuotesC):
|
||||||
self.mainConf.fmtDoubleQuotes[1] = fmtDoubleQuotesC
|
self.mainConf.fmtDoubleQuotes[1] = fmtDoubleQuotesC
|
||||||
else:
|
else:
|
||||||
self.theParent.makeAlert("Invalid quote symbol: %s" % fmtDoubleQuotesC, nwAlert.ERROR)
|
self.theParent.makeAlert(
|
||||||
|
"Invalid quote symbol: %s" % fmtDoubleQuotesC, nwAlert.ERROR
|
||||||
|
)
|
||||||
validEntries = False
|
validEntries = False
|
||||||
|
|
||||||
showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
||||||
|
|||||||
+24
-21
@@ -19,8 +19,9 @@ from os import path
|
|||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtSvg import QSvgWidget
|
from PyQt5.QtSvg import QSvgWidget
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout, QGroupBox, QCheckBox,
|
QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout,
|
||||||
QLabel, QComboBox, QLineEdit, QPushButton, QFileDialog, QProgressBar, QSpinBox, QMessageBox
|
QGroupBox, QCheckBox, QLabel, QComboBox, QLineEdit, QPushButton,
|
||||||
|
QFileDialog, QProgressBar, QSpinBox, QMessageBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.project.document import NWDoc
|
from nw.project.document import NWDoc
|
||||||
@@ -201,9 +202,10 @@ class GuiExport(QDialog):
|
|||||||
# Check that encoding was successful
|
# Check that encoding was successful
|
||||||
if outFile.texCodecFail:
|
if outFile.texCodecFail:
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"Failed to escape unicode characters while writing LaTeX file. The generated "
|
"Failed to escape unicode characters while writing LaTeX "
|
||||||
".tex file may not build properly. Make sure the python package '{package:s}' "
|
"file. The generated .tex file may not build properly. "
|
||||||
"is installed and working."
|
"Make sure the python package '{package:s}' is installed "
|
||||||
|
"and working."
|
||||||
).format(
|
).format(
|
||||||
package = packageRefURL("latexcodec")
|
package = packageRefURL("latexcodec")
|
||||||
), nwAlert.WARN)
|
), nwAlert.WARN)
|
||||||
@@ -343,27 +345,31 @@ class GuiExportMain(QWidget):
|
|||||||
}
|
}
|
||||||
FMT_HELP = {
|
FMT_HELP = {
|
||||||
FMT_NWD : (
|
FMT_NWD : (
|
||||||
"Exports a document using the novelWriter markdown format. The files selected by the "
|
"Exports a document using the novelWriter markdown format. "
|
||||||
"filters are appended as-is, including comments and other settings."
|
"The files selected by the filters are appended as-is, "
|
||||||
|
"including comments and other settings."
|
||||||
),
|
),
|
||||||
FMT_TXT : (
|
FMT_TXT : (
|
||||||
"Exports a plain text file. All formatting is stripped and comments are in square "
|
"Exports a plain text file. All formatting is stripped and "
|
||||||
"brackets."
|
"comments are in square brackets."
|
||||||
),
|
),
|
||||||
FMT_MD : (
|
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 : (
|
FMT_HTML : (
|
||||||
"Exports a plain html5 file. Comments are wrapped in blocks with a yellow background "
|
"Exports a plain html5 file. Comments are wrapped in "
|
||||||
"colour."
|
"blocks with a yellow background colour."
|
||||||
),
|
),
|
||||||
FMT_TEX : (
|
FMT_TEX : (
|
||||||
"Exports a LaTeX file that can be compiled to PDF using for instance PDFLaTeX. "
|
"Exports a LaTeX file that can be compiled to PDF using "
|
||||||
"Comments are exported as LaTeX comments."
|
"for instance PDFLaTeX. Comments are exported as LaTeX "
|
||||||
|
"comments."
|
||||||
),
|
),
|
||||||
FMT_PDOC : (
|
FMT_PDOC : (
|
||||||
"Exports first to markdown or html5. The file is then passed on to Pandoc for a "
|
"Exports first to markdown or html5. The file is then "
|
||||||
"second stage. Use the Pandoc tab for settings up the conversion."
|
"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.Options()
|
||||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||||
saveTo = QFileDialog.getSaveFileName(
|
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:
|
if saveTo:
|
||||||
self.exportPath.setText(saveTo[0])
|
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 v2 (.epub2)", self.FMT_EPUB2)
|
||||||
self.outputFormat.addItem("ePUB eBook v3 (.epub3)", self.FMT_EPUB3)
|
self.outputFormat.addItem("ePUB eBook v3 (.epub3)", self.FMT_EPUB3)
|
||||||
self.outputFormat.addItem("Zim Wiki (.txt)", self.FMT_ZIM)
|
self.outputFormat.addItem("Zim Wiki (.txt)", self.FMT_ZIM)
|
||||||
# self.outputFormat.currentIndexChanged.connect(self._updateFormat)
|
|
||||||
|
|
||||||
optIdx = self.outputFormat.findData(self.optState.getSetting("pFormat"))
|
optIdx = self.outputFormat.findData(self.optState.getSetting("pFormat"))
|
||||||
if optIdx == -1:
|
if optIdx == -1:
|
||||||
@@ -674,9 +680,6 @@ class GuiExportPandoc(QWidget):
|
|||||||
self.outerBox.addWidget(self.guiInfo, 0, 0)
|
self.outerBox.addWidget(self.guiInfo, 0, 0)
|
||||||
self.outerBox.addWidget(self.guiOutput, 1, 0)
|
self.outerBox.addWidget(self.guiOutput, 1, 0)
|
||||||
self.outerBox.setRowStretch(2, 1)
|
self.outerBox.setRowStretch(2, 1)
|
||||||
# self.outerBox.setColumnStretch(0, 1)
|
|
||||||
# self.outerBox.setColumnStretch(1, 1)
|
|
||||||
# self.outerBox.setColumnStretch(2, 1)
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ from os import path
|
|||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtSvg import QSvgWidget
|
from PyQt5.QtSvg import QSvgWidget
|
||||||
from PyQt5.QtWidgets import (
|
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
|
from nw.enum import nwItemLayout, nwItemClass, nwItemType
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ from PyQt5.QtCore import Qt, QSize
|
|||||||
from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush, QStandardItemModel
|
from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush, QStandardItemModel
|
||||||
from PyQt5.QtSvg import QSvgWidget
|
from PyQt5.QtSvg import QSvgWidget
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QLabel,
|
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit,
|
||||||
QWidget, QTabWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QPushButton,
|
QLabel, QWidget, QTabWidget, QDialogButtonBox, QListWidget,
|
||||||
QColorDialog, QAbstractItemView, QTreeWidget, QTreeWidgetItem, QCheckBox
|
QListWidgetItem, QPushButton, QColorDialog, QAbstractItemView, QTreeWidget,
|
||||||
|
QTreeWidgetItem, QCheckBox
|
||||||
)
|
)
|
||||||
from nw.enum import nwAlert
|
from nw.enum import nwAlert
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ import nw
|
|||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon, QColor, QPixmap, QFont
|
from PyQt5.QtGui import QIcon, QColor, QPixmap, QFont
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QHeaderView,
|
QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QTreeWidgetItem,
|
||||||
QGridLayout, QLabel, QGroupBox, QCheckBox
|
QDialogButtonBox, QHeaderView, QGridLayout, QLabel, QGroupBox,
|
||||||
|
QCheckBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.tools.optlaststate import OptLastState
|
from nw.tools.optlaststate import OptLastState
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ from os import path
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon, QColor, QPixmap
|
from PyQt5.QtGui import QIcon, QColor, QPixmap
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem, QDialogButtonBox, QLabel,
|
QDialog, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem,
|
||||||
QPushButton, QHeaderView, QGridLayout, QGroupBox, QCheckBox
|
QDialogButtonBox, QLabel, QPushButton, QHeaderView, QGridLayout,
|
||||||
|
QGroupBox, QCheckBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.tools.optlaststate import OptLastState
|
from nw.tools.optlaststate import OptLastState
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ import nw
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer, QSizeF
|
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 (
|
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
|
from nw.project.document import NWDoc
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import nw
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtGui import QIcon, QFont, QColor
|
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.project.item import NWItem
|
||||||
from nw.constants import nwLabels
|
from nw.constants import nwLabels
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class GuiNoticeBar(QFrame):
|
|||||||
self.mainBox.setContentsMargins(8,2,2,2)
|
self.mainBox.setContentsMargins(8,2,2,2)
|
||||||
|
|
||||||
self.noteLabel = QLabel("Hi there!")
|
self.noteLabel = QLabel("Hi there!")
|
||||||
|
|
||||||
self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
|
self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
|
||||||
self.closeButton.clicked.connect(self.hideNote)
|
self.closeButton.clicked.connect(self.hideNote)
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import nw
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon
|
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
|
from nw.enum import nwDocAction
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import nw
|
|||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QFont
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QWidget, QHBoxLayout, QVBoxLayout, QLabel, QGroupBox, QScrollArea, QFrame, QToolButton,
|
QWidget, QHBoxLayout, QVBoxLayout, QLabel, QGroupBox, QScrollArea, QFrame,
|
||||||
QSizePolicy, QCheckBox, QGridLayout
|
QToolButton, QSizePolicy, QCheckBox, QGridLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.constants import nwLabels
|
from nw.constants import nwLabels
|
||||||
|
|||||||
+3
-1
@@ -78,7 +78,9 @@ class GuiMainMenu(QMenuBar):
|
|||||||
recentProject = self.mainConf.recentList[n]
|
recentProject = self.mainConf.recentList[n]
|
||||||
if recentProject == "": continue
|
if recentProject == "": continue
|
||||||
menuItem = QAction("%s" % recentProject, self.projMenu)
|
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.addAction(menuItem)
|
||||||
|
|
||||||
self.recentMenu.addSeparator()
|
self.recentMenu.addSeparator()
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import logging
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
from PyQt5.QtGui import QIcon, QColor, QPixmap
|
from PyQt5.QtGui import QIcon, QColor, QPixmap
|
||||||
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
|
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ import logging
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QRegularExpression
|
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
|
from nw.constants import nwUnicode
|
||||||
|
|
||||||
@@ -196,7 +198,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
))
|
))
|
||||||
|
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
"<(\S+?)>", {
|
r"<(\S+?)>", {
|
||||||
0 : self.hStyles["replace"],
|
0 : self.hStyles["replace"],
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -103,9 +103,12 @@ class NWDoc():
|
|||||||
docTemp = path.join(dataPath,docFile[:-3]+"tmp")
|
docTemp = path.join(dataPath,docFile[:-3]+"tmp")
|
||||||
docBack = path.join(dataPath,docFile[:-3]+"bak")
|
docBack = path.join(dataPath,docFile[:-3]+"bak")
|
||||||
|
|
||||||
if path.isfile(docTemp): unlink(docTemp)
|
if path.isfile(docTemp):
|
||||||
if path.isfile(docBack): rename(docBack,docTemp)
|
unlink(docTemp)
|
||||||
if path.isfile(docPath): rename(docPath,docBack)
|
if path.isfile(docBack):
|
||||||
|
rename(docBack,docTemp)
|
||||||
|
if path.isfile(docPath):
|
||||||
|
rename(docPath,docBack)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(docPath,mode="w",encoding="utf8") as outFile:
|
with open(docPath,mode="w",encoding="utf8") as outFile:
|
||||||
|
|||||||
@@ -390,7 +390,6 @@ class NWIndex():
|
|||||||
def buildNovelList(self):
|
def buildNovelList(self):
|
||||||
"""Build a list of the content of the novel.
|
"""Build a list of the content of the novel.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.novelList = []
|
self.novelList = []
|
||||||
self.novelOrder = []
|
self.novelOrder = []
|
||||||
for tHandle in self.theProject.treeOrder:
|
for tHandle in self.theProject.treeOrder:
|
||||||
@@ -399,7 +398,6 @@ class NWIndex():
|
|||||||
for tEntry in self.novelIndex[tHandle]:
|
for tEntry in self.novelIndex[tHandle]:
|
||||||
self.novelList.append(tEntry)
|
self.novelList.append(tEntry)
|
||||||
self.novelOrder.append("%s:%d" % (tHandle,tEntry[0]))
|
self.novelOrder.append("%s:%d" % (tHandle,tEntry[0]))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def buildReferenceList(self, tHandle):
|
def buildReferenceList(self, tHandle):
|
||||||
|
|||||||
@@ -194,8 +194,10 @@ class NWProject():
|
|||||||
self.projCache = path.join(self.projPath,"cache")
|
self.projCache = path.join(self.projPath,"cache")
|
||||||
self.projDict = path.join(self.projMeta, nwFiles.PROJ_DICT)
|
self.projDict = path.join(self.projMeta, nwFiles.PROJ_DICT)
|
||||||
|
|
||||||
if not self._checkFolder(self.projMeta): return
|
if not self._checkFolder(self.projMeta):
|
||||||
if not self._checkFolder(self.projCache): return
|
return
|
||||||
|
if not self._checkFolder(self.projCache):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
nwXML = etree.parse(fileName)
|
nwXML = etree.parse(fileName)
|
||||||
@@ -411,8 +413,8 @@ class NWProject():
|
|||||||
return False
|
return False
|
||||||
if self.projName == "":
|
if self.projName == "":
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"You must set a valid project name in project settings to use "
|
"You must set a valid project name in project settings to "
|
||||||
"the automatic project backup feature."
|
"use the automatic project backup feature."
|
||||||
), nwAlert.ERROR)
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
self.doBackup = True
|
self.doBackup = True
|
||||||
|
|||||||
Reference in New Issue
Block a user