From e9b789f89c3a54f067ef40c0cb48582e73e2a9a9 Mon Sep 17 00:00:00 2001 From: kjubik Date: Mon, 6 Jan 2025 13:47:13 +0100 Subject: [PATCH] add script for marking tasks as TODO based on student's index number --- kurwix.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 kurwix.py diff --git a/kurwix.py b/kurwix.py new file mode 100644 index 0000000..fe7baa8 --- /dev/null +++ b/kurwix.py @@ -0,0 +1,72 @@ +import os + +def find_tasks_to_do(indeks: int): + tasks_to_do = [] + + for task_id in range(49): + task_id_str = f"{task_id:02d}" + with open(f"TaskC{task_id_str}/description.txt", "r") as file: + description = file.read() + for line in description.splitlines(): + if "REMAINDER" in line: + remainder, divisor = parse_remainder(line) + if verify_task_should_be_done(indeks, remainder, divisor): + tasks_to_do.append(task_id) + + return tasks_to_do + + + +def parse_remainder(line: str): + parts = line.split(":")[1].strip().split("/") + remainder = int(parts[0]) + divisor = int(parts[1]) + return remainder, divisor + + + +def verify_task_should_be_done(indeks: int, remainder: int, divisor: int): + return indeks % divisor == remainder + + + + +def display_tasks_to_do(task_ids): + print("Twoje zadania to:") + for task_id in task_ids: + task_id_str = f"{task_id:02d}" + old_dir = f"TaskC{task_id_str}" + new_dir = f"{old_dir}_TODO" + os.rename(old_dir, new_dir) + print(f"- {task_id_str}") + print("Foldery z zadaniamy zostały oznaczone jako TODO.\nPowodzenia!") + + + +def run(): + RED = "\033[31m" + RESET = "\033[39m" + + while True: + try: + indeks = int(input("Podaj swój numer indeksu: ")) + break + except ValueError: + print(RED + "Proszę podać prawidłowy numer indeksu.\n" + RESET) + + display_tasks_to_do(find_tasks_to_do(indeks)) + + return + + + +if __name__ == "__main__": + print('''---------------------------------- + _ _ +| | ___ _ _ ____ _(_)_ __ +| |/ / | | | '__\ \ /\ / / \ \/ / +| <| |_| | | \ V V /| |> < +|_|\_\\\\__,_|_| \_/\_/ |_/_/\_\\ + +----------------------------------\n''') + run()