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
50
todo.py
50
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:
|
||||||
priority = int(task.priority, base=16)
|
text = "" # pylint: disable=C0103
|
||||||
old_range = max_prio - min_prio + 1
|
text_color = COLOR_LIST[new_range][default_priority]
|
||||||
new_range = len(set(list_of_priorities))
|
if task.priority:
|
||||||
priority = int(((priority - min_prio) * new_range) / old_range)
|
priority = int(task.priority, base=16)
|
||||||
if "due" not in task.tags:
|
priority = int(((priority - min_prio) * new_range) / old_range)
|
||||||
print("<span size=\"larger\" weight=\"bold\">" + task.priority +
|
text = text + """<span size="larger" weight="bold">""" + task.priority + "</span>: "
|
||||||
"</span>: <span size=\"medium\" foreground=\"" + COLOR_LIST[new_range][priority] + "\">" + task.text +
|
text_color = COLOR_LIST[new_range][priority]
|
||||||
"</span>")
|
text += """<span size="medium" foreground=\"""" + text_color + "\">" + task.text + "</span>"
|
||||||
else:
|
if "due" in task.tags:
|
||||||
print("<span size=\"larger\" weight=\"bold\">" + task.priority +
|
from datetime import datetime
|
||||||
"</span>: <span size=\"medium\" background=\"white\" foreground=\"black\">" + task.tags["due"] +
|
due_date = datetime.strptime(task.tags["due"], "%Y-%m-%d")
|
||||||
"</span> <span size=\"medium\" foreground=\"" + COLOR_LIST[new_range][priority] + "\">" + task.text +
|
now = datetime.now()
|
||||||
"</span>")
|
tomorrow = datetime(year=now.year, month=now.month, day=now.day + 1)
|
||||||
print("--", " ".join(["@" + x for x in task.contexts]))
|
text += " <span size=\"medium\""
|
||||||
print("--", " ".join(["+" + x for x in task.projects]))
|
if due_date < tomorrow:
|
||||||
print("--", " ".join([key + ": " + value for key, value in task.tags.items() if key != "due"]))
|
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]))
|
||||||
|
if task.projects:
|
||||||
|
print("--", " ".join(["+" + x for x in task.projects]))
|
||||||
|
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