def checkprojects(self): for p in Project.objects.filter(): n_nextactions = NextAction.objects.filter(project=p.id, done=False).count() n_waiting = WaitingFor.objects.filter(project=p.id,done=False).count() keep = inp("{p.name} ({n_nextactions} actions, waiting for {n_waiting})\nKeep? [y/n]".format(**locals()),['x in "yn"']) if keep == 'n': sure = inp("Sure? [Y/n]") if sure == 'Y': p.delete()
def add_actionable_cli(): choice = inp("[e] = execute | [d] = delegate | [l] = list", ['x in "edl"']) if choice == "e": raw_input("Gogogo! 2 minutes! [RET]\n> ") print("Win.") elif choice == "d": raw_input("Delegate that shit! [RET]\n> ") waiting = inp("Would you like to create a waiting-for action? (y/n)", ['x in "yn"']) if waiting == "y": create_action(type = 'w') elif choice == "l": create_action()
def _create_cli(cls, action): for c in Context.objects.all(): print(c.pk, c.name) choice = inp("Please choose a context or type ADD", ['x.isdigit() or x == "ADD"']) if choice == "ADD": name = inp("Name?") context = Context.create(name) context.save() elif choice.isdigit(): context = Context.objects.get(pk = int(choice)) action.context = context action.duration = inp("How long, in minutes, should this take?", ['x.isdigit()']) return action
def create_cli(cls): project = cls() project.name = inp("Name?", ['len(x) > 3']) print("Now, please select a parent.") project.parent = cls.get_cli() project.save() return project
def add_action_cli(item = None): if item: print(item.info) choice = inp("[p] = project | [f] = file | [a] = actionable | [d] = delete", ['x in "pfad" and len(x) == 1']) else: choice = inp("[p] = project | [a] = actionable", ["x == 'p' or x == 'a'"]) if choice == "p": Project.create_cli() elif choice == "f": item.filed = True item.save() elif choice == "a": add_actionable_cli() elif choice == "d": item.delete() print("That's it for this item.") sleep(1)
def checkactions(self, model): for a in model.objects.filter(done=False): print(a.project and a.project.name) print(a.name) do = inp("[c = complete | d = delete | k = keep]",['x in "cdk"','len(x)==1']) if do == 'c': a.done = True a.save() elif do == 'd': a.delete()
def create_action(type = None): if not type: type = inp("[n] = next action | [w] = waiting for | [s] = some day/maybe | [d] = deadline | [r] = recurrent action", ['x in "nwsdr"']) if type == "n": action = NextAction.create_cli() elif type == "w": action = WaitingFor.create_cli() elif type == "s": action = SomeDayAction.create_cli() elif type == "d": action = DeadlineAction.create_cli() elif type == "r": action = RecurrentAction.create_cli() action.save()
def create_cli(cls): """Create item, using cli prompts""" action = cls() action.name = inp("Action name?", []) print("Please describe the action, type 'OK' if done.") lines = [] while True: line = raw_input("> ") if line == "OK": break lines.append(line) action.description = "\n".join(lines) action.project = Project.get_cli() action = cls._create_cli(action) return action
def _iteritems(self): items = Item.objects.filter(filed = False) print("You have {n} items in your inbox".format(n = items.count())) for item in items: while True: try: add_action_cli(item) except KeyboardInterrupt: cont = raw_input("Start over from last item? (RET/^C)\n> ") else: more = inp("Continue? (y/n)", ['x == "y" or x == "n"']) if more == 'n': break if not item.filed: item.delete()
def brainstorm(self): add = inp("Would you like to add any actions you can think of now? [y/n]",["x in 'yn'"]) while add == 'y': create_action() add = inp("Anything else? [y/n]",["x in 'yn'"])
def checkweek(self, day): week(day) add = inp("Anything to add? [y/n]", ['x in "yn"']) while add == 'y': create_action() add = inp("Anything to add? [y/n]", ['x in "yn"'])
def _create_cli(cls, action): action = NextAction._create_cli(action) action.deadline = inp("Deadline date?") return action
def get_cli(cls): for p in cls.objects.all(): print(p.id, p.name) _id = inp("Select project (or type N)", ['x.isdigit() or x == "N"']) if not _id == "N": return cls.objects.get(pk = _id)
def _create_cli(cls, action): action = Action._create_cli(action) action.cron = inp("Please input cron") action.duration = inp("How long, in minutes, should this take?", ['x.isdigit()']) return action
def _getcontexts(self): for c in Context.objects.all(): print(c.pk, c.name) contexts = inp("please choose contexts:", ['x.isdigit()']) return contexts