From 2b48db5b624ead079759415fd8ad3c2c290f8afa Mon Sep 17 00:00:00 2001 From: Arnas Udovicius Date: Wed, 14 Feb 2018 17:16:03 +0200 Subject: [PATCH] create task, list --- abcex.py | 33 ++++++++++++++ bcolors.py | 12 ++++++ default.db | Bin 61440 -> 61440 bytes model.py | 57 +++++++++++++++++++++++++ tags | 35 ++++++++++++++- ztm.py | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 abcex.py create mode 100644 bcolors.py create mode 100644 model.py diff --git a/abcex.py b/abcex.py new file mode 100644 index 0000000..5894864 --- /dev/null +++ b/abcex.py @@ -0,0 +1,33 @@ +# from https://github.com/zordsdavini/abcex + +class Abcex: + + abc_map = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 'a', + 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f', 16: 'g', 17: 'h', 18: + 'i', 19: 'j', 20: 'k', 21: 'l', 22: 'm', 23: 'n', 24: 'o', 25: 'p', + 26: 'q', 27: 'r', 28: 's', 29: 't', 30: 'u', 31: 'v', 32: 'w', 33: + 'x', 34: 'y', 35: 'z'} + + inv_abc_map = {str(v): k for k, v in abc_map.items()} + + def encode(self, number): + number = int(number) + result = '' + + while number > 0: + result = "%s%s" % (self.abc_map[number % 36], result) + number //= 36 + + return result + + + def decode(self, string): + result = 0 + string = str(string) + string = reversed(str(string)) + + for i, c in enumerate(string): + result = 36**i * self.inv_abc_map[c] + result + + return result + diff --git a/bcolors.py b/bcolors.py new file mode 100644 index 0000000..224364b --- /dev/null +++ b/bcolors.py @@ -0,0 +1,12 @@ +# from https://stackoverflow.com/questions/287871/print-in-terminal-with-colors + + +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' diff --git a/default.db b/default.db index 8de0e5e12c1c4c4c50d92c840f7947c3e1d581d9..3c7c613b9f8faa1c2d704e1d8922a1a66e8da523 100644 GIT binary patch delta 464 zcmZp8z})bFd4jZ{5Ca1PKM=D6F(VL5Ow=*f6k^b0b>!vhVBqDDVBnv@@5c9)Z!?bz z_X$2p-t}CJoQWI~yy?7hoQWGJPGHw=a^q(g7Zqh}$uCJv%1JFrEY1dD4(A|O#}HSA z5Jx8;R|O@IkkaIhT!xdl?IzoEn@=w1*5=mXQUHR)Wrp5+ZY|dcE>guLtWuXsVjsq zT`~C(_ZJpm=wwXZ#p9|7WNc6uWsJ_uOG&K&`71s%B_7Vk}o;5nYeT& zOLEErIfuBvFu8L~R^XMLe3eIw!-btqTwRngdU8Im7$e8zHeR`Ukf{n9nJJn9Y;5A% zqKx^Oc`2zCAklcBJ@KV*E<4mQp?;o$p{@#^elD&NU^gMDQ}Fi#3n^#-^=blxMFQ+A sQHZbDc-g=qmBGUGq0KA?fAkj>C@gYNSX7Vz0F9-(_ \(__ __) (OO) + / _/ ( ) ,'.--.) + / / )( / /|_|_\\ + / ( ( )| \_.--. + ( `-. )/ '. \) \\ + `--.._) ( `-.(_.' + +Task manager from Zordsdavini (2018) + ''') + + self.menu() + + def menu(self): + menu = input('What you want to do? (?+/tcq) ') + + if menu == 'q': + print('bye o/') + sys.exit(0) + + elif menu == '?': + self.about() + + elif menu == '/': + self.search() + + elif menu == '+': + self.add() + + def about(self): + print(''' +Short instruction +----------------- +? - help (this dialog) ++ - add +/ - search +t - tag manager +c - configuration +q - exit + ''') + self.menu() + + def search(self): + tasks = [] + tasksData = self.model.get_all_tasks() + if not tasksData: + self.add() + tasksData = self.model.get_all_tasks() + + for t in self.model.get_all_tasks(): + tasks.append('%s: %s' % (t[1], t[2])) + + selected = self.fzfCall(tasks) + + def add(self): + print('\n' + bcolors.HEADER + 'Adding task\n' + bcolors.ENDC) + description = input('Description: ') + aid = self.model.create_task_draft(description) + self.manage_task(aid) + + + def add_tag(self, task_id): + question = input('Do you want to add tag? ([y]/n) ') + if question == 'y' or question == '': + self.add_tag(task_id) + pass + + def manage_task(self, aid): + task = self.model.get_task(aid) + print('\n' + bcolors.HEADER + 'Managing: [' + task['aid'] + '] ' + task['description'] + '\n' + bcolors.ENDC) + + print() + self.manage_task_menu(aid) + + def manage_task_menu(self, aid): + menu = input('What you want to do? (?e*+-v&q) ') + + if menu == 'q': + print('bye o/') + sys.exit(0) + + elif menu == '?': + self.manage_task_about(aid) + + def manage_task_about(self, aid): + print(''' +Short instruction +----------------- +? - help (this dialog) +e - edit content +* - toggle long term ++ - add tag +- - remove tag +v - mark done +& - add child task +q - exit + ''') + self.manage_task_menu(aid) + + def fzfCall(self, elements): + try: + p = subprocess.Popen(['echo', '\n'.join(elements)], stdout=subprocess.PIPE) + p2 = subprocess.check_output(('fzf'), stdin=p.stdout) + return p2 + except: + return None + + +if __name__ == '__main__': + a = Main() + a.run()