Use Ruff for linting and fix a ton of issues
This commit is contained in:
+2
-2
@@ -102,7 +102,7 @@ def buildSampleZip(args: argparse.Namespace | None = None) -> None:
|
||||
sys.exit(1)
|
||||
|
||||
print("")
|
||||
print("Built file: %s" % dstSample)
|
||||
print(f"Built file: {dstSample}")
|
||||
print("")
|
||||
|
||||
return
|
||||
@@ -242,7 +242,7 @@ def buildTranslationAssets(args: argparse.Namespace | None = None) -> None:
|
||||
for item in srcDir.iterdir():
|
||||
if item.is_file() and item.suffix == ".qm":
|
||||
item.rename(dstDir / item.name)
|
||||
print("Moved: %s -> %s" % (item.relative_to(ROOT_DIR), dstRel / item.name))
|
||||
print(f"Moved: {item.relative_to(ROOT_DIR)} -> {dstRel / item.name}")
|
||||
|
||||
print("")
|
||||
|
||||
|
||||
@@ -65,12 +65,12 @@ def embedPython(bldDir: Path, outDir: Path) -> None:
|
||||
"""Embed Python library."""
|
||||
print("Adding Python embeddable ...")
|
||||
|
||||
pyVers = "%d.%d.%d" % (sys.version_info[:3])
|
||||
pyVers = ".".join(str(v) for v in sys.version_info[:3])
|
||||
zipFile = f"python-{pyVers}-embed-amd64.zip"
|
||||
pyZip = bldDir / zipFile
|
||||
if not pyZip.is_file():
|
||||
pyUrl = f"https://www.python.org/ftp/python/{pyVers}/{zipFile}"
|
||||
print("Downloading: %s" % pyUrl)
|
||||
print(f"Downloading: {pyUrl}")
|
||||
urllib.request.urlretrieve(pyUrl, pyZip)
|
||||
|
||||
print("Extracting ...")
|
||||
@@ -192,7 +192,7 @@ def main(args: argparse.Namespace) -> None:
|
||||
print("")
|
||||
|
||||
numVers, _, _ = extractVersion()
|
||||
print("Version: %s" % numVers)
|
||||
print(f"Version: {numVers}")
|
||||
|
||||
bldDir = ROOT_DIR / "dist"
|
||||
outDir = bldDir / "novelWriter"
|
||||
|
||||
+6
-6
@@ -44,17 +44,17 @@ def extractVersion(beQuiet: bool = False) -> tuple[str, str, str]:
|
||||
try:
|
||||
for aLine in initFile.read_text(encoding="utf-8").splitlines():
|
||||
if aLine.startswith("__version__"):
|
||||
numVers = getValue((aLine))
|
||||
numVers = getValue(aLine)
|
||||
if aLine.startswith("__hexversion__"):
|
||||
hexVers = getValue((aLine))
|
||||
hexVers = getValue(aLine)
|
||||
if aLine.startswith("__date__"):
|
||||
relDate = getValue((aLine))
|
||||
relDate = getValue(aLine)
|
||||
except Exception as exc:
|
||||
print("Could not read file: %s" % initFile)
|
||||
print(f"Could not read file: {initFile}")
|
||||
print(str(exc))
|
||||
|
||||
if not beQuiet:
|
||||
print("novelWriter version: %s (%s) at %s" % (numVers, hexVers, relDate))
|
||||
print(f"novelWriter version: {numVers} ({hexVers}) at {relDate}")
|
||||
|
||||
return numVers, hexVers, relDate
|
||||
|
||||
@@ -95,7 +95,7 @@ def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
|
||||
copyFiles = ["LICENSE.md", "CREDITS.md", "pyproject.toml"]
|
||||
for copyFile in copyFiles:
|
||||
shutil.copyfile(copyFile, dst / copyFile)
|
||||
print("Copied: %s" % copyFile)
|
||||
print(f"Copied: {copyFile}")
|
||||
|
||||
writeFile(dst / "MANIFEST.in", (
|
||||
"include LICENSE.md\n"
|
||||
|
||||
@@ -165,7 +165,7 @@ def _fixXml(svg: ET.Element) -> str:
|
||||
|
||||
|
||||
def _writeThemeFile(
|
||||
path: Path, name: str, author: str, license: str, icons: dict[str, ET.Element]
|
||||
path: Path, name: str, author: str, license_: str, icons: dict[str, ET.Element]
|
||||
) -> None:
|
||||
"""Write an icon theme file."""
|
||||
with open(path.with_suffix(".icons"), mode="w", encoding="utf-8") as out:
|
||||
@@ -173,7 +173,7 @@ def _writeThemeFile(
|
||||
out.write("# Meta\n")
|
||||
out.write(f"meta:name = {name}\n")
|
||||
out.write(f"meta:author = {author}\n")
|
||||
out.write(f"meta:license = {license}\n")
|
||||
out.write(f"meta:license = {license_}\n")
|
||||
out.write("\n")
|
||||
out.write("# Icons\n")
|
||||
for key, svg in icons.items():
|
||||
|
||||
Reference in New Issue
Block a user