Compare commits
2 commits
5a737d418d
...
030baf137e
| Author | SHA1 | Date | |
|---|---|---|---|
| 030baf137e | |||
| c9fdf7b839 |
1 changed files with 3 additions and 3 deletions
6
todo.py
6
todo.py
|
|
@ -30,7 +30,7 @@ def list_tasks(parent=None):
|
||||||
print(f"Listing tasks in '{parent if parent else 'root'}'")
|
print(f"Listing tasks in '{parent if parent else 'root'}'")
|
||||||
if parent:
|
if parent:
|
||||||
todo = {parent: todo[parent]}
|
todo = {parent: todo[parent]}
|
||||||
print(render_todo(todo))
|
print(build_todo(todo))
|
||||||
|
|
||||||
|
|
||||||
def complete_task(task, parent=None):
|
def complete_task(task, parent=None):
|
||||||
|
|
@ -104,7 +104,7 @@ def parse_todo() -> dict[str, dict]:
|
||||||
return todo
|
return todo
|
||||||
|
|
||||||
|
|
||||||
def render_todo(todo: dict[str, dict]) -> str:
|
def build_todo(todo: dict[str, dict]) -> str:
|
||||||
lines = ["# A ToDo list", ""]
|
lines = ["# A ToDo list", ""]
|
||||||
for task, task_data in todo.items(): # type: str, dict
|
for task, task_data in todo.items(): # type: str, dict
|
||||||
lines.append(f"- [{'x' if task_data["completed"] else ' '}] {task}")
|
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]):
|
def write_todo(todo: dict[str, dict]):
|
||||||
with open(todo_file, "w") as f:
|
with open(todo_file, "w") as f:
|
||||||
f.write(render_todo(todo))
|
f.write(build_todo(todo))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue