73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
|
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()
|