do a conditional writing for each task
we're _much_ more flexible this way.
This commit is contained in:
parent
e1e5fe38b9
commit
df7980c6b5
1 changed files with 31 additions and 19 deletions
42
todo.py
42
todo.py
|
@ -44,25 +44,37 @@ COLOR_LIST = {
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
list_of_tasks = todotxtio.from_file(TODO_TXT_PATH)
|
list_of_tasks = todotxtio.from_file(TODO_TXT_PATH)
|
||||||
list_of_priorities = [int(x.priority, base=16) for x in list_of_tasks]
|
list_of_priorities = [int(x.priority, base=16) for x in list_of_tasks if x.priority and x.priority.isalnum()]
|
||||||
max_prio = max(list_of_priorities)
|
max_prio = max(list_of_priorities) if list_of_priorities else 1
|
||||||
min_prio = min(list_of_priorities)
|
min_prio = min(list_of_priorities) if list_of_priorities else 1
|
||||||
|
new_range = len(set(list_of_priorities)) if list_of_priorities else 1
|
||||||
|
old_range = max_prio - min_prio + 1
|
||||||
|
default_priority = int((max_prio - min_prio) * new_range / old_range)
|
||||||
print("📋", len(list_of_tasks))
|
print("📋", len(list_of_tasks))
|
||||||
print("---")
|
print("---")
|
||||||
for task in list_of_tasks:
|
for task in list_of_tasks:
|
||||||
|
text = "" # pylint: disable=C0103
|
||||||
|
text_color = COLOR_LIST[new_range][default_priority]
|
||||||
|
if task.priority:
|
||||||
priority = int(task.priority, base=16)
|
priority = int(task.priority, base=16)
|
||||||
old_range = max_prio - min_prio + 1
|
|
||||||
new_range = len(set(list_of_priorities))
|
|
||||||
priority = int(((priority - min_prio) * new_range) / old_range)
|
priority = int(((priority - min_prio) * new_range) / old_range)
|
||||||
if "due" not in task.tags:
|
text = text + """<span size="larger" weight="bold">""" + task.priority + "</span>: "
|
||||||
print("<span size=\"larger\" weight=\"bold\">" + task.priority +
|
text_color = COLOR_LIST[new_range][priority]
|
||||||
"</span>: <span size=\"medium\" foreground=\"" + COLOR_LIST[new_range][priority] + "\">" + task.text +
|
text += """<span size="medium" foreground=\"""" + text_color + "\">" + task.text + "</span>"
|
||||||
"</span>")
|
if "due" in task.tags:
|
||||||
else:
|
from datetime import datetime
|
||||||
print("<span size=\"larger\" weight=\"bold\">" + task.priority +
|
due_date = datetime.strptime(task.tags["due"], "%Y-%m-%d")
|
||||||
"</span>: <span size=\"medium\" background=\"white\" foreground=\"black\">" + task.tags["due"] +
|
now = datetime.now()
|
||||||
"</span> <span size=\"medium\" foreground=\"" + COLOR_LIST[new_range][priority] + "\">" + task.text +
|
tomorrow = datetime(year=now.year, month=now.month, day=now.day + 1)
|
||||||
"</span>")
|
text += " <span size=\"medium\""
|
||||||
|
if due_date < tomorrow:
|
||||||
|
text += """ foreground="white" background="red" weight="bold\""""
|
||||||
|
text += ">due:" + task.tags["due"] + "</span>"
|
||||||
|
print(text)
|
||||||
|
if task.contexts:
|
||||||
print("--", " ".join(["@" + x for x in task.contexts]))
|
print("--", " ".join(["@" + x for x in task.contexts]))
|
||||||
|
if task.projects:
|
||||||
print("--", " ".join(["+" + x for x in task.projects]))
|
print("--", " ".join(["+" + x for x in task.projects]))
|
||||||
print("--", " ".join([key + ": " + value for key, value in task.tags.items() if key != "due"]))
|
other_tags = [key + ": " + value for key, value in task.tags.items() if key != "due"]
|
||||||
|
if other_tags:
|
||||||
|
print("--", " ".join(other_tags))
|
||||||
|
|
Loading…
Reference in a new issue