Compare commits

..

2 commits

Author SHA1 Message Date
030baf137e
Small improvements 2024-11-11 16:39:47 -05:00
c9fdf7b839
Create a python todo utility 2024-11-11 16:35:03 -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(render_todo(todo))
print(build_todo(todo))
def complete_task(task, parent=None):
@ -104,7 +104,7 @@ def parse_todo() -> dict[str, dict]:
return todo
def render_todo(todo: dict[str, dict]) -> str:
def build_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 render_todo(todo: dict[str, dict]) -> str:
def write_todo(todo: dict[str, dict]):
with open(todo_file, "w") as f:
f.write(render_todo(todo))
f.write(build_todo(todo))
def main():