sorting todos

This commit is contained in:
James Turk 2024-07-27 13:03:47 -04:00
parent ddc8c90a30
commit 7367befa87
2 changed files with 13 additions and 3 deletions

View File

@ -7,13 +7,13 @@ A suite of tools for dealing with a directory of markdown files.
- TODO: more flags
- [ ] filters
- [ ] sorting
- TODO: add config file
- TODO: add config file {by:2024-08-01}
- [ ] make file types configurable
- [ ] look in local dir, then XDG_HOME
- DONE: support checkboxes
- [x] scan lists
- [x] percent complete
- TODO: decide on more permanent name
- TODO: decide on more permanent name {by:2024-08-15}
- IDEA: recurring?
- IDEA: track changes
- DONE: add color {by: 2024-07-26}

View File

@ -10,6 +10,7 @@ from rich.console import Console
console = Console()
now = datetime.datetime.now()
SORT_ORDER = ["TODO", "IDEA", "DONE"]
ALL_TODO_RE = re.compile(
r"""^
(?:\s*-\s*)?
@ -31,7 +32,6 @@ TODO_TODO_RE = re.compile(
def get_files(dirname):
print(dirname, not dirname)
if not dirname:
dirname = "~/wiki/"
else:
@ -88,6 +88,15 @@ class TodoItem:
" | ".join(self.tags),
]
def status_sort(self):
return SORT_ORDER.index(self.status)
def due(self):
for t in self.tags:
if t.startswith("by"):
return t
return "zzzzzzz" # sort to end
def subtask_nested(self):
if not self.subtasks:
return ""
@ -169,6 +178,7 @@ def todos(dirname):
output = [] # list of data
for file in get_files(dirname):
output += pull_todos(file)
output.sort(key=lambda item: (item.status_sort(), item.due()), reverse=False)
table = lod_table(output)
console.print(table)