def share(observer, tid): """Share task with other users""" try: manager = Actions() manager.share_task(observer, tid) except Exception as e: click.echo(e)
def change(login): """Set user as current (Sign In)""" try: manager = Actions() manager.change_user(login) except Exception as e: print(e)
def delete_task(tid): """Deleting task""" try: manager = Actions() manager.delete_task(tid) except IndexError as e: click.echo("Can't find task")
def archieve(): """Show list of completed tasks""" manager = Actions() archieved_tasks = manager.get_archieve() if archieved_tasks is None: click.secho("Archieve is empty", bg='red', fg='white') return console_utils.print_tree(manager, archieved_tasks)
def plans(): manager = Actions() schedulers = manager.get_schedulers() for scheduler in schedulers: click.echo("Scheduler ID(sid): " + scheduler.sid + click.style("\nTask title: " + scheduler.task.title + "\n\n", fg='white', bold=True))
def planned(sid): """Show list of completed tasks""" manager = Actions() tasks = manager.get_planned_list(sid) if not tasks: click.echo("No tasks with such sid") return click.secho("Scheduler ID: " + sid, fg='yellow') for task in tasks: click.echo(task.tid + " - " + task.title)
def tag(name): """Ordering task by tag""" try: manager = Actions() ordered_tasks = manager.order_by_tag(name) click.echo("Ordered by tag:" + name) click.echo() console_utils.format_print_ordered(ordered_tasks) except IndexError as e: click.echo(e) except Exception as e: click.echo(e)
def show(tid): """Showing full info about task: choose INDEX or TID""" try: manager = Actions() task = manager.get_task_by_tid(tid) subtasks = manager.get_subtasks(tid) console_utils.format_print_info(task, subtasks, manager) except IndexError as e: click.echo("IndexError: " + e) except Exception as e: click.echo("Something went wrong: {}".format(e))
def priority(name): """Ordering task by priority""" try: manager = Actions() priority = Priority[name] ordered_tasks = manager.order_by_priority(priority) click.echo("Ordered by priority:" + click.style(name, bg='red', fg='white')) click.echo() console_utils.format_print_ordered(ordered_tasks) except IndexError as e: click.echo("IndexError: " + e) except Exception as e: click.echo(e)
def edit(tid, tag, description, title, priority, end): """Editing tasks. Choose index and field""" try: manager = Actions() if tid is None: raise ValueError("Input tid!") manager.edit_task(tid, title=title, tag=tag, priority=priority, description=description, end=end) except Exception as e: click.echo(e)
def scheduler(startdate, enddate, tag, description, title, reminder, observers, priority, interval): """Crating new scheduler for task""" observers = console_utils.split_str_to_list(observers) priority = Priority[priority] tag = Tag(tag) manager = Actions() manager.add_scheduler(title, datetime.strptime(startdate, "%Y-%m-%d"), datetime.strptime(enddate, "%Y-%m-%d"), interval, tag=tag, description=description, observers=observers, reminder=datetime.strptime(reminder, "%H:%M"), priority=priority)
def current(): """Showing current user""" try: manager = Actions() current = manager.task_storage.load_user( manager.task_storage.current_uid) click.echo("Login: {}".format(current.login)) click.echo("Full name: {} {}".format(current.name, current.surname)) click.echo("UID: {}".format(current.uid)) except Exception as e: print(e)
def status(tid, status): """Change status of task: done, undone, process. Required data: TID, status name""" try: manager = Actions() status = Status[status] if status == Status.DONE: manager.complete_task(tid) elif status == Status.PROCESS: manager.begin_task(tid) elif status == Status.UNDONE: manager.uncomplete_task(tid) except ValueError as e: print(e) except Exception as e: print(e)
def add(startdate, enddate, tag, description, title, reminder, observers, priority, parent): """Adding new task""" try: observers = console_utils.split_str_to_list(observers) priority = Priority[priority] tag = Tag(tag) manager = Actions() manager.add_task(title, datetime.strptime(startdate, "%Y-%m-%d"), datetime.strptime(enddate, "%Y-%m-%d"), tag=tag, description=description, observers=observers, reminder=datetime.strptime(reminder, "%H:%M"), priority=priority, parent=parent) except ValueError as e: click.echo("ValueError:" + str(e)) except TypeError: click.echo("Check your data!") except Exception as e: click.echo("Exception:" + str(type(e)))
def main(): actions = Actions() # TODO Nespresso, what else? print("Exiting application...")
def add_user(login, name, surname): """Add new user""" manager = Actions() manager.add_new_user(login, name, surname)
def edit(sid, title, interval): manager = Actions() manager.edit_scheduler(sid, title=title, interval=interval)
def cli(): """Task Manager (tman) application for managing tasks and events""" #try: manager = Actions() manager.get_schedulers()
def list(): """Showing list of user's tasks""" manager = Actions() tasks_list = manager.get_tasks_list() console_utils.print_tree(manager, tasks_list)
def make_link(first, second): """Make link between 2 tasks """ manager = Actions() manager.make_link(first, second)