Make comments and docstrings comply with PEP8
This commit is contained in:
+15
-11
@@ -100,9 +100,9 @@ class TextFile():
|
||||
self.fileName = path.basename(filePath)
|
||||
if path.isfile(filePath) and self.mainConf.showGUI:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self.theParent, "Overwrite", ("File '%s' already exists.<br>Do you want to overwrite it?" % self.fileName)
|
||||
)
|
||||
msgRes = msgBox.question(self.theParent, "Overwrite", (
|
||||
"File '%s' already exists.<br>Do you want to overwrite it?" % self.fileName
|
||||
))
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
@@ -137,11 +137,14 @@ class TextFile():
|
||||
return True
|
||||
|
||||
def checkInclude(self, tHandle):
|
||||
"""This function checks whether a file should be included in the export or not. For standard
|
||||
note and novel files, this is controlled by the options selected by the user. For other
|
||||
files classified as non-exportable, a few checks must be made, and the following are not:
|
||||
"""This function checks whether a file should be included in the
|
||||
export or not. For standard note and novel files, this is
|
||||
controlled by the options selected by the user. For other files
|
||||
classified as non-exportable, a few checks must be made, and the
|
||||
following are not:
|
||||
* Items that are not actual files.
|
||||
* Items that have been orphaned which are tagged as NO_LAYOUT and NO_CLASS.
|
||||
* Items that have been orphaned which are tagged as NO_LAYOUT
|
||||
and NO_CLASS.
|
||||
* Items that appear in the TRASH folder
|
||||
"""
|
||||
|
||||
@@ -168,8 +171,9 @@ class TextFile():
|
||||
##
|
||||
|
||||
def _doOpenFile(self, filePath):
|
||||
"""This function does the actual opening of the file, and can be overloaded by a subclass
|
||||
that uses a different file format that requires a different approach.
|
||||
"""This function does the actual opening of the file, and can be
|
||||
overloaded by a subclass that uses a different file format that
|
||||
requires a different approach.
|
||||
"""
|
||||
try:
|
||||
self.outFile = open(filePath,mode="wt+",encoding="utf8")
|
||||
@@ -180,8 +184,8 @@ class TextFile():
|
||||
return True
|
||||
|
||||
def _doCloseFile(self):
|
||||
"""This function closes the file, and is meant to be overloaded by the subclass for other
|
||||
file formats.
|
||||
"""This function closes the file, and is meant to be overloaded
|
||||
by the subclass for other file formats.
|
||||
"""
|
||||
if self.outFile is not None:
|
||||
self.outFile.close()
|
||||
|
||||
@@ -27,8 +27,9 @@ class ToHtml(Tokenizer):
|
||||
return
|
||||
|
||||
def setPreview(self, forPreview, doComments):
|
||||
"""If we're using this class to generate markdown preview, we need to make a few changes to
|
||||
formatting, which is selected by this flag.
|
||||
"""If we're using this class to generate markdown preview, we
|
||||
need to make a few changes to formatting, which is selected by
|
||||
this flag.
|
||||
"""
|
||||
|
||||
self.forPreview = forPreview
|
||||
|
||||
@@ -28,7 +28,8 @@ class ToLaTeX(Tokenizer):
|
||||
return
|
||||
|
||||
def doPostProcessing(self):
|
||||
"""The latexcodec misses dashes and non-breaking spaces, so we do those here.
|
||||
"""The latexcodec misses dashes and non-breaking spaces, so we
|
||||
do those here.
|
||||
"""
|
||||
|
||||
repDict = {
|
||||
@@ -62,8 +63,9 @@ class ToLaTeX(Tokenizer):
|
||||
begText = "\\begin{center}\n"
|
||||
endText = "\\end{center}\n\n"
|
||||
|
||||
# First check if we have a comment or plain text, as they need some
|
||||
# extra replacing before we proceed to wrapping and final formatting.
|
||||
# First check if we have a comment or plain text, as they
|
||||
# need some extra replacing before we proceed to wrapping
|
||||
# and final formatting.
|
||||
if tType == self.T_COMMENT:
|
||||
tText = "%% %s" % tText
|
||||
|
||||
@@ -75,8 +77,9 @@ class ToLaTeX(Tokenizer):
|
||||
|
||||
tLen = len(tText)
|
||||
|
||||
# Then the text can receive final formatting before we append it to the results.
|
||||
# We also store text lines in a buffer and merge them only when we find an empty line
|
||||
# Then the text can receive final formatting before we
|
||||
# append it to the results. We also store text lines in a
|
||||
# buffer and merge them only when we find an empty line
|
||||
# indicating a new paragraph.
|
||||
if tType == self.T_EMPTY:
|
||||
if len(thisPar) > 0:
|
||||
|
||||
@@ -55,8 +55,9 @@ class ToMarkdown(Tokenizer):
|
||||
thisPar = []
|
||||
for tType, tText, tFormat, tAlign in self.theTokens:
|
||||
|
||||
# First check if we have a comment or plain text, as they need some
|
||||
# extra replacing before we proceed to wrapping and final formatting.
|
||||
# First check if we have a comment or plain text, as they
|
||||
# need some extra replacing before we proceed to wrapping
|
||||
# and final formatting.
|
||||
if tType == self.T_COMMENT:
|
||||
tText = " %s" % tText
|
||||
|
||||
@@ -68,7 +69,8 @@ class ToMarkdown(Tokenizer):
|
||||
|
||||
tLen = len(tText)
|
||||
|
||||
# The text can now be word wrapped, if we have requested this and it's needed.
|
||||
# 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(
|
||||
@@ -77,8 +79,9 @@ class ToMarkdown(Tokenizer):
|
||||
else:
|
||||
tText = tWrap.fill(tText)
|
||||
|
||||
# Then the text can receive final formatting before we append it to the results.
|
||||
# We also store text lines in a buffer and merge them only when we find an empty line,
|
||||
# Then the text can receive final formatting before we
|
||||
# append it to the results. We also store text lines in a
|
||||
# buffer and merge them only when we find an empty line,
|
||||
# indicating a new paragraph.
|
||||
if tType == self.T_EMPTY:
|
||||
if len(thisPar) > 0:
|
||||
|
||||
@@ -61,8 +61,9 @@ class ToText(Tokenizer):
|
||||
thisPar = []
|
||||
for tType, tText, tFormat, tAlign in self.theTokens:
|
||||
|
||||
# First check if we have a comment or plain text, as they need some
|
||||
# extra replacing before we proceed to wrapping and final formatting.
|
||||
# First check if we have a comment or plain text, as they
|
||||
# need some extra replacing before we proceed to wrapping
|
||||
# and final formatting.
|
||||
if tType == self.T_COMMENT:
|
||||
tText = "[%s]" % tText
|
||||
|
||||
@@ -74,7 +75,8 @@ class ToText(Tokenizer):
|
||||
|
||||
tLen = len(tText)
|
||||
|
||||
# The text can now be word wrapped, if we have requested this and it's needed.
|
||||
# The text can now be word wrapped, if we have requested
|
||||
# this and it's needed.
|
||||
if tAlign == self.A_CENTRE:
|
||||
if self.wordWrap > 0:
|
||||
if tLen > self.wordWrap:
|
||||
@@ -88,8 +90,9 @@ class ToText(Tokenizer):
|
||||
if self.wordWrap > 0 and tLen > self.wordWrap:
|
||||
tText = tWrap.fill(tText)
|
||||
|
||||
# Then the text can receive final formatting before we append it to the results.
|
||||
# We also store text lines in a buffer and merge them only when we find an empty line,
|
||||
# Then the text can receive final formatting before we
|
||||
# append it to the results. We also store text lines in a
|
||||
# buffer and merge them only when we find an empty line,
|
||||
# indicating a new paragraph.
|
||||
if tType == self.T_EMPTY:
|
||||
if len(thisPar) > 0:
|
||||
|
||||
@@ -153,10 +153,11 @@ class Tokenizer():
|
||||
return
|
||||
|
||||
def tokenizeText(self):
|
||||
"""Scan the text for either lines starting with specific characters that indicate headers,
|
||||
comments, commands etc, or just contains plain text. in the case of plain text, apply the
|
||||
same RegExes that the syntax highlighter uses and save the locations of these formatting
|
||||
tags into the token array.
|
||||
"""Scan the text for either lines starting with specific
|
||||
characters that indicate headers, comments, commands etc, or
|
||||
just contains plain text. in the case of plain text, apply the
|
||||
same RegExes that the syntax highlighter uses and save the
|
||||
locations of these formatting tags into the token array.
|
||||
"""
|
||||
|
||||
# RegExes for adding formatting tags within text lines
|
||||
|
||||
Reference in New Issue
Block a user