Update linting for utils
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Configuration file for the Sphinx documentation builder.
|
||||
Documentation: http://www.sphinx-doc.org/en/master/config
|
||||
"""
|
||||
""" # noqa
|
||||
|
||||
# -- Imports -----------------------------------------------------------------
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ not yet have a qtbase_xx.qm file shipped with Qt.
|
||||
|
||||
If a qtbase_xx.qm file already exists, do not add a translation for the
|
||||
entries generated from this file.
|
||||
"""
|
||||
""" # noqa
|
||||
|
||||
from PyQt6.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"""
|
||||
novelWriter – Start Script
|
||||
==========================
|
||||
"""
|
||||
""" # noqa
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
+1
-8
@@ -23,7 +23,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 argparse
|
||||
@@ -50,7 +50,6 @@ OS_WIN = sys.platform.startswith("win32")
|
||||
def printVersion(args: argparse.Namespace) -> None:
|
||||
"""Print the novelWriter version and exit."""
|
||||
print(extractVersion(beQuiet=True)[0], end=None)
|
||||
return
|
||||
|
||||
|
||||
def installPackages(args: argparse.Namespace) -> None:
|
||||
@@ -79,8 +78,6 @@ def installPackages(args: argparse.Namespace) -> None:
|
||||
print(str(exc))
|
||||
sys.exit(1)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def cleanBuildDirs(args: argparse.Namespace) -> None:
|
||||
"""Recursively delete the 'build' and 'dist' folders."""
|
||||
@@ -111,8 +108,6 @@ def cleanBuildDirs(args: argparse.Namespace) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def genMacOSPlist(args: argparse.Namespace) -> None:
|
||||
"""Set necessary values for .plist file for MacOS build."""
|
||||
@@ -134,8 +129,6 @@ def genMacOSPlist(args: argparse.Namespace) -> None:
|
||||
print(f"Writing Info.plist to {outDir}/Info.plist")
|
||||
writeFile(outDir / "Info.plist", plistXML)
|
||||
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""Parse command line options and run the commands."""
|
||||
|
||||
+1
-12
@@ -17,7 +17,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 argparse
|
||||
@@ -62,8 +62,6 @@ def buildSampleZip(args: argparse.Namespace | None = None) -> None:
|
||||
print(f"Built file: {dstSample}")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def importI18nUpdates(args: argparse.Namespace) -> None:
|
||||
"""Import new translation files from a zip file."""
|
||||
@@ -94,8 +92,6 @@ def importI18nUpdates(args: argparse.Namespace) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def updateTranslationSources(args: argparse.Namespace) -> None:
|
||||
"""Build the lang.ts files for Qt Linguist."""
|
||||
@@ -157,8 +153,6 @@ def updateTranslationSources(args: argparse.Namespace) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def buildTranslationAssets(args: argparse.Namespace | None = None) -> None:
|
||||
"""Build the lang.qm files for Qt Linguist."""
|
||||
@@ -203,8 +197,6 @@ def buildTranslationAssets(args: argparse.Namespace | None = None) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def cleanBuiltAssets(args: argparse.Namespace | None = None) -> None:
|
||||
"""Remove assets built by this script."""
|
||||
@@ -223,8 +215,6 @@ def cleanBuiltAssets(args: argparse.Namespace | None = None) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def buildAllAssets(args: argparse.Namespace) -> None:
|
||||
"""Build all assets."""
|
||||
@@ -232,4 +222,3 @@ def buildAllAssets(args: argparse.Namespace) -> None:
|
||||
buildSampleZip()
|
||||
buildTranslationAssets()
|
||||
buildPdfDocAssets()
|
||||
return
|
||||
|
||||
@@ -17,7 +17,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 argparse
|
||||
@@ -134,5 +134,3 @@ def appImage(args: argparse.Namespace) -> None:
|
||||
toUpload(bldFile)
|
||||
toUpload(updFile)
|
||||
toUpload(shaFile)
|
||||
|
||||
return
|
||||
|
||||
@@ -17,7 +17,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 argparse
|
||||
@@ -25,7 +25,7 @@ import argparse
|
||||
|
||||
def runPyinstaller() -> None:
|
||||
"""Run the pyinstaller."""
|
||||
import PyInstaller.__main__
|
||||
import PyInstaller.__main__ # type: ignore
|
||||
|
||||
build = ["novelWriter.py", "--clean", "--windowed", "--onedir", "--noconfirm"]
|
||||
build += ["--name", "novelwriter"]
|
||||
@@ -35,10 +35,7 @@ def runPyinstaller() -> None:
|
||||
build += ["--add-data", "novelwriter/assets:assets"]
|
||||
PyInstaller.__main__.run(build)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def main(args: argparse.Namespace) -> None:
|
||||
"""Entry point function."""
|
||||
runPyinstaller()
|
||||
return
|
||||
|
||||
@@ -17,7 +17,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 argparse
|
||||
@@ -155,17 +155,16 @@ def makeDebianPackage(
|
||||
|
||||
|
||||
def debian(args: argparse.Namespace) -> None:
|
||||
"""Build a .deb package"""
|
||||
"""Build a .deb package."""
|
||||
if sys.platform != "linux":
|
||||
print("ERROR: Command 'build-deb' can only be used on Linux")
|
||||
sys.exit(1)
|
||||
signKey = SIGN_KEY if args.sign else None
|
||||
makeDebianPackage(signKey)
|
||||
return
|
||||
|
||||
|
||||
def launchpad(args: argparse.Namespace) -> None:
|
||||
"""Wrapper for building Debian packages for Launchpad."""
|
||||
"""Build Debian packages for Launchpad."""
|
||||
if sys.platform != "linux":
|
||||
print("ERROR: Command 'build-ubuntu' can only be used on Linux")
|
||||
sys.exit(1)
|
||||
@@ -215,5 +214,3 @@ def launchpad(args: argparse.Namespace) -> None:
|
||||
for dCmd in dputCmd:
|
||||
print(f" > {dCmd}")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
@@ -17,7 +17,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 argparse
|
||||
@@ -60,8 +60,6 @@ def prepareCode(outDir: Path) -> None:
|
||||
print("Done")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def embedPython(bldDir: Path, outDir: Path) -> None:
|
||||
"""Embed Python library."""
|
||||
@@ -82,8 +80,6 @@ def embedPython(bldDir: Path, outDir: Path) -> None:
|
||||
print("Done")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def installRequirements(libDir: Path) -> None:
|
||||
"""Install dependencies."""
|
||||
@@ -93,7 +89,6 @@ def installRequirements(libDir: Path) -> None:
|
||||
])
|
||||
print("Done")
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def main(args: argparse.Namespace) -> None:
|
||||
@@ -157,5 +152,3 @@ def main(args: argparse.Namespace) -> None:
|
||||
print("")
|
||||
print("Done")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
+3
-12
@@ -17,7 +17,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 shutil
|
||||
@@ -88,7 +88,6 @@ def copySourceCode(dst: Path) -> None:
|
||||
if item.is_file():
|
||||
shutil.copyfile(item, dst / relSrc)
|
||||
print("Copied:", relSrc, flush=True)
|
||||
return
|
||||
|
||||
|
||||
def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
|
||||
@@ -114,8 +113,6 @@ def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
|
||||
text = text.replace("setup/description_pypi.md", "data/description_short.txt")
|
||||
writeFile(dst / "pyproject.toml", text)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def toUpload(srcPath: str | Path, dstName: str | None = None) -> None:
|
||||
"""Copy a file produced by one of the build functions to the upload
|
||||
@@ -125,7 +122,6 @@ def toUpload(srcPath: str | Path, dstName: str | None = None) -> None:
|
||||
uplDir.mkdir(exist_ok=True)
|
||||
srcPath = Path(srcPath)
|
||||
shutil.copyfile(srcPath, uplDir / (dstName or srcPath.name))
|
||||
return
|
||||
|
||||
|
||||
def makeCheckSum(sumFile: str, cwd: Path | None = None) -> str:
|
||||
@@ -174,9 +170,7 @@ def appdataXml() -> str:
|
||||
"""Generate the appdata XML content."""
|
||||
raw = readFile(SETUP_DIR / "description_short.txt")
|
||||
desc = " ".join(raw.strip().splitlines()).strip()
|
||||
xml = readFile(SETUP_DIR / "novelwriter.appdata.xml")
|
||||
xml = xml.format(description=desc)
|
||||
return xml
|
||||
return readFile(SETUP_DIR / "novelwriter.appdata.xml").format(description=desc)
|
||||
|
||||
|
||||
def readFile(file: Path) -> str:
|
||||
@@ -197,7 +191,6 @@ def freshFolder(path: Path) -> None:
|
||||
print("Removing:", str(path), flush=True)
|
||||
shutil.rmtree(path)
|
||||
path.mkdir()
|
||||
return
|
||||
|
||||
|
||||
def systemCall(cmd: list, cwd: Path | str | None = None, env: dict | None = None) -> int:
|
||||
@@ -213,7 +206,7 @@ def systemCall(cmd: list, cwd: Path | str | None = None, env: dict | None = None
|
||||
|
||||
|
||||
def removeRedundantQt(qtBase: Path) -> None:
|
||||
"""Delete Qt files that are not needed"""
|
||||
"""Delete Qt files that are not needed."""
|
||||
|
||||
def unlinkIfFound(file: Path) -> None:
|
||||
if file.is_file():
|
||||
@@ -274,5 +267,3 @@ def removeRedundantQt(qtBase: Path) -> None:
|
||||
deleteFolder(qt6Dir / "qml")
|
||||
deleteFolder(plugDir / "qmlls")
|
||||
deleteFolder(plugDir / "qmllint")
|
||||
|
||||
return
|
||||
|
||||
+1
-9
@@ -17,7 +17,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 argparse
|
||||
@@ -61,12 +61,9 @@ def updateDocsTranslationSources(args: argparse.Namespace) -> None:
|
||||
print("Done")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def buildHtmlDocs(args: argparse.Namespace | None = None) -> None:
|
||||
"""Build the documentation files."""
|
||||
|
||||
print("")
|
||||
print("Building HTML Docs")
|
||||
print("==================")
|
||||
@@ -105,12 +102,9 @@ def buildHtmlDocs(args: argparse.Namespace | None = None) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def buildPdfDocAssets(args: argparse.Namespace | None = None) -> None:
|
||||
"""Build the documentation PDF files."""
|
||||
|
||||
print("")
|
||||
print("Building Docs Manuals")
|
||||
print("=====================")
|
||||
@@ -146,5 +140,3 @@ def buildPdfDocAssets(args: argparse.Namespace | None = None) -> None:
|
||||
raise Exception(f"Build returned error code {ex}")
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
+1
-12
@@ -17,7 +17,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 argparse
|
||||
@@ -197,7 +197,6 @@ def _writeThemeFile(
|
||||
out.write(f"icon:{key:<15s} = {_fixXml(svg)}\n")
|
||||
print(f"- Wrote: {len(icons)} icons")
|
||||
print(f"- Target: {path.relative_to(UTILS.parent)}")
|
||||
return
|
||||
|
||||
|
||||
def _updateRepo(path: Path, name: str) -> None:
|
||||
@@ -208,7 +207,6 @@ def _updateRepo(path: Path, name: str) -> None:
|
||||
else:
|
||||
subprocess.call(["git", "pull"], cwd=path)
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def _downloadIconPack(path: Path, name: str) -> None:
|
||||
@@ -220,7 +218,6 @@ def _downloadIconPack(path: Path, name: str) -> None:
|
||||
with zipfile.ZipFile(zipFile, "r") as inFile:
|
||||
inFile.extractall(path)
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
@@ -257,8 +254,6 @@ def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
"""Process Font Awesome icons of a given spec and write output file."""
|
||||
@@ -303,8 +298,6 @@ def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
"""Process Remix icons of a given spec and write output file."""
|
||||
@@ -347,8 +340,6 @@ def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def main(args: argparse.Namespace) -> None:
|
||||
"""Build icon themes entry point."""
|
||||
@@ -423,5 +414,3 @@ def main(args: argparse.Namespace) -> None:
|
||||
|
||||
print("Done")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user