sorting todos
This commit is contained in:
parent
ddc8c90a30
commit
7367befa87
@ -7,13 +7,13 @@ A suite of tools for dealing with a directory of markdown files.
|
|||||||
- TODO: more flags
|
- TODO: more flags
|
||||||
- [ ] filters
|
- [ ] filters
|
||||||
- [ ] sorting
|
- [ ] sorting
|
||||||
- TODO: add config file
|
- TODO: add config file {by:2024-08-01}
|
||||||
- [ ] make file types configurable
|
- [ ] make file types configurable
|
||||||
- [ ] look in local dir, then XDG_HOME
|
- [ ] look in local dir, then XDG_HOME
|
||||||
- DONE: support checkboxes
|
- DONE: support checkboxes
|
||||||
- [x] scan lists
|
- [x] scan lists
|
||||||
- [x] percent complete
|
- [x] percent complete
|
||||||
- TODO: decide on more permanent name
|
- TODO: decide on more permanent name {by:2024-08-15}
|
||||||
- IDEA: recurring?
|
- IDEA: recurring?
|
||||||
- IDEA: track changes
|
- IDEA: track changes
|
||||||
- DONE: add color {by: 2024-07-26}
|
- DONE: add color {by: 2024-07-26}
|
||||||
|
@ -10,6 +10,7 @@ from rich.console import Console
|
|||||||
console = Console()
|
console = Console()
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
|
||||||
|
SORT_ORDER = ["TODO", "IDEA", "DONE"]
|
||||||
ALL_TODO_RE = re.compile(
|
ALL_TODO_RE = re.compile(
|
||||||
r"""^
|
r"""^
|
||||||
(?:\s*-\s*)?
|
(?:\s*-\s*)?
|
||||||
@ -31,7 +32,6 @@ TODO_TODO_RE = re.compile(
|
|||||||
|
|
||||||
|
|
||||||
def get_files(dirname):
|
def get_files(dirname):
|
||||||
print(dirname, not dirname)
|
|
||||||
if not dirname:
|
if not dirname:
|
||||||
dirname = "~/wiki/"
|
dirname = "~/wiki/"
|
||||||
else:
|
else:
|
||||||
@ -88,6 +88,15 @@ class TodoItem:
|
|||||||
" | ".join(self.tags),
|
" | ".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):
|
def subtask_nested(self):
|
||||||
if not self.subtasks:
|
if not self.subtasks:
|
||||||
return ""
|
return ""
|
||||||
@ -169,6 +178,7 @@ def todos(dirname):
|
|||||||
output = [] # list of data
|
output = [] # list of data
|
||||||
for file in get_files(dirname):
|
for file in get_files(dirname):
|
||||||
output += pull_todos(file)
|
output += pull_todos(file)
|
||||||
|
output.sort(key=lambda item: (item.status_sort(), item.due()), reverse=False)
|
||||||
table = lod_table(output)
|
table = lod_table(output)
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user