Compare commits

..

3 Commits

Author SHA1 Message Date
Danilo Reyes
5ad8fc0dc8 print exist status 2026-02-28 19:40:55 -06:00
Danilo Reyes
12df61c524 validation for user input 2026-02-28 19:39:05 -06:00
Danilo Reyes
f2d5c1324a check for x.com and legacy twitter.com 2026-02-28 19:37:20 -06:00
3 changed files with 20 additions and 4 deletions

View File

@@ -71,7 +71,7 @@ class User:
"""Writes the input line into it's respective list, """Writes the input line into it's respective list,
depending on what website it belongs to.""" depending on what website it belongs to."""
if re.search("x", line): if re.search(r"(x\\.com|twitter\\.com)", line):
self.append_list("main", validate_x_link(line)) self.append_list("main", validate_x_link(line))
elif re.search(r"kemono\.party", line): elif re.search(r"kemono\.party", line):
self.append_list("kemono", line) self.append_list("kemono", line)

View File

@@ -128,7 +128,16 @@ def print_webcomics(webcomics: Dict[str, Dict]) -> int:
for index, entry in enumerate(webcomics["webcomics"]): for index, entry in enumerate(webcomics["webcomics"]):
print(list_lines(index, entry["name"])) print(list_lines(index, entry["name"]))
return int(input("Select a webcomic: ")) max_index = len(webcomics["webcomics"]) - 1
while True:
raw = input("Select a webcomic: ").strip()
if not raw.isdigit():
print("Please enter a number.")
continue
choice = int(raw)
if 0 <= choice <= max_index:
return choice
print(f"Please enter a number between 0 and {max_index}.")
def webcomic_manager(): def webcomic_manager():

View File

@@ -60,7 +60,12 @@ def clean_cache(directory: Path):
shutil.rmtree(directory) shutil.rmtree(directory)
def run(command: str | Sequence[str], verbose: bool, cwd: Path | None = None) -> None: def run(
command: str | Sequence[str],
verbose: bool,
cwd: Path | None = None,
check: bool = False,
) -> None:
"""Run command in a subprocess""" """Run command in a subprocess"""
# pylint: disable=subprocess-run-check # pylint: disable=subprocess-run-check
# This toggle allows for a really wasy debug when using -v # This toggle allows for a really wasy debug when using -v
@@ -77,7 +82,9 @@ def run(command: str | Sequence[str], verbose: bool, cwd: Path | None = None) ->
else: else:
args = list(command) args = list(command)
subprocess.run(args, check=False, cwd=cwd) result = subprocess.run(args, check=check, cwd=cwd)
if not check and result.returncode != 0:
LOG.warning("Command failed (%s): %s", result.returncode, args)
def list_lines(i: int, line: str) -> str: def list_lines(i: int, line: str) -> str: