Created
January 11, 2020 12:34
-
-
Save Vostbur/f47fc1a5229e485fe549ef00f7cbab8e to your computer and use it in GitHub Desktop.
Very small and simple task manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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