Update linting for main code
This commit is contained in:
@@ -20,7 +20,7 @@ General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
""" # noqa
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
@@ -56,6 +56,7 @@ T_TextStyle = tuple[QTextBlockFormat, QTextCharFormat]
|
||||
|
||||
|
||||
def newBlock(cursor: QTextCursor, bFmt: QTextBlockFormat) -> None:
|
||||
"""Insert a new block if not at the beginning of the document."""
|
||||
if cursor.position() > 0:
|
||||
cursor.insertBlock(bFmt)
|
||||
else:
|
||||
@@ -63,7 +64,7 @@ def newBlock(cursor: QTextCursor, bFmt: QTextBlockFormat) -> None:
|
||||
|
||||
|
||||
class ToQTextDocument(Tokenizer):
|
||||
"""Core: QTextDocument Writer
|
||||
"""Core: QTextDocument Writer.
|
||||
|
||||
Extend the Tokenizer class to generate a QTextDocument output. This
|
||||
is intended for usage in the document viewer and build tool preview.
|
||||
@@ -92,8 +93,6 @@ class ToQTextDocument(Tokenizer):
|
||||
self._pageSize = QPageSize(QPageSize.PageSizeId.A4)
|
||||
self._pageMargins = QMarginsF(20.0, 20.0, 20.0, 20.0)
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Properties
|
||||
##
|
||||
@@ -113,17 +112,14 @@ class ToQTextDocument(Tokenizer):
|
||||
"""Set the document page size and margins in millimetres."""
|
||||
self._pageSize = QPageSize(QSizeF(width, height), QPageSize.Unit.Millimeter)
|
||||
self._pageMargins = QMarginsF(left, top, right, bottom)
|
||||
return
|
||||
|
||||
def setShowNewPage(self, state: bool) -> None:
|
||||
"""Add markers for page breaks."""
|
||||
self._newPage = state
|
||||
return
|
||||
|
||||
def disableAnchors(self) -> None:
|
||||
"""Disable anchors for when writing to file."""
|
||||
self._anchors = False
|
||||
return
|
||||
|
||||
##
|
||||
# Class Methods
|
||||
@@ -200,8 +196,6 @@ class ToQTextDocument(Tokenizer):
|
||||
|
||||
self._init = True
|
||||
|
||||
return
|
||||
|
||||
def doConvert(self) -> None:
|
||||
"""Write text tokens into the document."""
|
||||
if not self._init:
|
||||
@@ -297,8 +291,6 @@ class ToQTextDocument(Tokenizer):
|
||||
self._document.setPageSize(printer.pageRect(QPrinter.Unit.DevicePixel).size())
|
||||
self._document.print(printer)
|
||||
|
||||
return
|
||||
|
||||
def closeDocument(self) -> None:
|
||||
"""Run close document tasks."""
|
||||
self._document.blockSignals(True)
|
||||
@@ -333,8 +325,6 @@ class ToQTextDocument(Tokenizer):
|
||||
|
||||
self._document.blockSignals(False)
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
@@ -439,8 +429,6 @@ class ToQTextDocument(Tokenizer):
|
||||
# Insert whatever is left in the buffer
|
||||
cursor.insertText(stripEscape(temp[start:]), cFmt)
|
||||
|
||||
return
|
||||
|
||||
def _insertNewPageMarker(self, cursor: QTextCursor) -> None:
|
||||
"""Insert a new page marker."""
|
||||
if self._newPage:
|
||||
@@ -475,8 +463,6 @@ class ToQTextDocument(Tokenizer):
|
||||
if root := self._document.rootFrame():
|
||||
cursor.swap(root.lastCursorPosition())
|
||||
|
||||
return
|
||||
|
||||
def _genHeadStyle(self, hType: BlockTyp, hKey: str, rFmt: QTextBlockFormat) -> T_TextStyle:
|
||||
"""Generate a heading style set."""
|
||||
mTop, mBottom = self._mHead.get(hType, (0.0, 0.0))
|
||||
|
||||
Reference in New Issue
Block a user