Browse Source

linting with ruff

master
Holger Frey 4 days ago
parent
commit
f021037ee6
  1. 1
      work_helpers/_natural_sort.py
  2. 5
      work_helpers/excel2changelog.py
  3. 3
      work_helpers/excel2pylist.py
  4. 4
      work_helpers/password.py
  5. 3
      work_helpers/random_int.py
  6. 6
      work_helpers/sensospot_rename.py
  7. 13
      work_helpers/sg_mbp_build.py

1
work_helpers/_natural_sort.py

@ -11,7 +11,6 @@ from http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-or @@ -11,7 +11,6 @@ from http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-or
import re
_NATURAL_SORT_REGEX_DIGITS = re.compile("([0-9]+)")

5
work_helpers/excel2changelog.py

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
import click
import re
import click
import pyperclip
a2z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -64,7 +65,7 @@ def clipboard_to_changelog( @@ -64,7 +65,7 @@ def clipboard_to_changelog(
)
line_count = len(result)
if line_count == 1:
print(f"Copied one line to the clipboard")
print("Copied one line to the clipboard")
print(result[0])
else:
print(f"Copied {line_count} lines to the clipboard")

3
work_helpers/excel2pylist.py

@ -31,8 +31,7 @@ def pad_field(index, t): @@ -31,8 +31,7 @@ def pad_field(index, t):
value, length = t
if index == 0:
return value.rjust(length)
else:
return value.ljust(length)
return value.ljust(length)
def pad_fields(iterable, lengths):

4
work_helpers/password.py

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
import click
import itertools
import random
import pyperclip
import click
import pyperclip
lowers = "abcdefghijklmnopqrstuvwxyz"
uppers = lowers.upper()

3
work_helpers/random_int.py

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
import click
import random
import click
import pyperclip

6
work_helpers/sensospot_rename.py

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
"""rename sensospot images"""
import click
import pathlib
import shutil
import click
RENAME_MAP_NAME = "rename_map.txt"
IMAGE_SUFFIXES = {".tif", ".jpg"}
@ -50,7 +50,7 @@ def _parse_rename_map(content: str) -> tuple[str, str]: @@ -50,7 +50,7 @@ def _parse_rename_map(content: str) -> tuple[str, str]:
for i, line in enumerate(lines, start=1):
if not line or line.startswith("#"):
continue
if not "\t" in line:
if "\t" not in line:
raise ValueError(f"No tab in line {i}: '{line}'")
yield line.split("\t", maxsplit=1)
@ -81,7 +81,7 @@ def sensospot_rename(directory): @@ -81,7 +81,7 @@ def sensospot_rename(directory):
if not map_file.is_file():
write_rename_map(map_file)
click.echo(f"Prepared rename map at '{map_file!s}'")
click.echo(f"Rerun the command after editing the file.")
click.echo("Rerun the command after editing the file.")
else:
click.echo(f"Reading rename map at '{map_file!s}'")
try:

13
work_helpers/sg_mbp_build.py

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
import click
import pathlib
import pyperclip
import shutil
import sys
from typing import Iterable
from dataclasses import dataclass
from datetime import datetime
from typing import Iterable
import click
import pyperclip
Pathlike = str | pathlib.Path
@ -285,8 +285,7 @@ def sg_mbp_build(dev_version): @@ -285,8 +285,7 @@ def sg_mbp_build(dev_version):
new_folder_path = PATH_WIN_DESKTOP / new_folder_name
if new_folder_path.exists():
raise MBPExcecption(f"Folder exists on desktop: {new_folder_name}")
else:
new_folder_path.mkdir()
new_folder_path.mkdir()
copy_workbooks(group, new_folder_path, build_version)
copy_frms(group, new_folder_path, build_version)
@ -364,7 +363,7 @@ def create_changelog_entry(cwd: Pathlike, new_version: str) -> None: @@ -364,7 +363,7 @@ def create_changelog_entry(cwd: Pathlike, new_version: str) -> None:
show_default="next minor version",
)
def sg_mbp_new_version(version):
"""
r"""
creates a new version folder, new excel changes files and modifies the overall changelog
in "E:\Safeguard-MBP-issues"
"""

Loading…
Cancel
Save