Skip to content

Instantly share code, notes, and snippets.

@Vostbur
Created January 11, 2020 12:34
Show Gist options
  • Save Vostbur/f47fc1a5229e485fe549ef00f7cbab8e to your computer and use it in GitHub Desktop.
Save Vostbur/f47fc1a5229e485fe549ef00f7cbab8e to your computer and use it in GitHub Desktop.
Very small and simple task manager
# -*- coding: utf-8 -*-
import re
import sys
tasks = set()
pattern = re.compile(r"/\w+")
def del_task(text):
global tasks
tmp_set = {i for i in tasks if text in i}
if tmp_set:
if len(tmp_set) > 1:
print("Exits simular tasks:", "; ".join(list(tmp_set)))
else:
tasks -= tmp_set
else:
print("Task not found")
actions = {"/exit": "sys.exit()",
"/add": "tasks.add(text)",
"/del": "del_task(text)"}
while True:
text = input("Please, type /add {task}, /del {task} or /exit : ")
match = pattern.search(text)
command = match[0] if match else ""
text = pattern.sub("", text).strip()
if command in actions:
eval(actions[command])
print("\n".join(list(tasks)) if tasks else "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment