Compare commits

..

2 commits

Author SHA1 Message Date
5a737d418d
Small improvements 2024-11-11 16:42:38 -05:00
aa09137df6
Create a python todo utility 2024-11-11 16:42:06 -05:00

View file

@ -30,7 +30,7 @@ def list_tasks(parent=None):
print(f"Listing tasks in '{parent if parent else 'root'}'")
if parent:
todo = {parent: todo[parent]}
print(build_todo(todo))
print(render_todo(todo))
def complete_task(task, parent=None):
@ -104,7 +104,7 @@ def parse_todo() -> dict[str, dict]:
return todo
def build_todo(todo: dict[str, dict]) -> str:
def render_todo(todo: dict[str, dict]) -> str:
lines = ["# A ToDo list", ""]
for task, task_data in todo.items(): # type: str, dict
lines.append(f"- [{'x' if task_data["completed"] else ' '}] {task}")
@ -116,7 +116,7 @@ def build_todo(todo: dict[str, dict]) -> str:
def write_todo(todo: dict[str, dict]):
with open(todo_file, "w") as f:
f.write(build_todo(todo))
f.write(render_todo(todo))
def main():