diff --git a/todo.py b/todo.py
index f93ecb5..3ef4bd4 100755
--- a/todo.py
+++ b/todo.py
@@ -44,25 +44,37 @@ COLOR_LIST = {
if __name__ == "__main__":
list_of_tasks = todotxtio.from_file(TODO_TXT_PATH)
- list_of_priorities = [int(x.priority, base=16) for x in list_of_tasks]
- max_prio = max(list_of_priorities)
- min_prio = min(list_of_priorities)
+ 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) if list_of_priorities else 1
+ 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("---")
for task in list_of_tasks:
- 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)
- if "due" not in task.tags:
- print("" + task.priority +
- ": " + task.text +
- "")
- else:
- print("" + task.priority +
- ": " + task.tags["due"] +
- " " + task.text +
- "")
- print("--", " ".join(["@" + x for x in task.contexts]))
- print("--", " ".join(["+" + x for x in task.projects]))
- print("--", " ".join([key + ": " + value for key, value in task.tags.items() if key != "due"]))
+ text = "" # pylint: disable=C0103
+ text_color = COLOR_LIST[new_range][default_priority]
+ if task.priority:
+ priority = int(task.priority, base=16)
+ priority = int(((priority - min_prio) * new_range) / old_range)
+ text = text + """""" + task.priority + ": "
+ text_color = COLOR_LIST[new_range][priority]
+ text += """" + task.text + ""
+ if "due" in task.tags:
+ from datetime import datetime
+ due_date = datetime.strptime(task.tags["due"], "%Y-%m-%d")
+ now = datetime.now()
+ tomorrow = datetime(year=now.year, month=now.month, day=now.day + 1)
+ text += " due:" + task.tags["due"] + ""
+ 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))