コード例 #1
0
ファイル: burndown.py プロジェクト: wasche/dotfiles
def load(argv):
    todoFile = argv.pop(0)
    doneFile = argv.pop(0)

    pLOE = re.compile('LOE: (\d*\.?\d+)d')
    pDingo = re.compile('dingo(\d+)')

    skip = set()
    while len(argv) > 0:
        arg = argv.pop(0)
        if arg[:1] == '-':
            skip.add(arg[1:])

    todos = TodoTxt(todoFile, doneFile)
    for p in todos.projects():
        if len(p.getContexts() & skip) > 0:
            continue
        remaining = filter(lambda t: not t.completed, p.tasks)
        if len(remaining) == 0:
            continue;

        total = len(p.tasks)
        completed = filter(lambda t: t.completed, p.tasks)
        remaining = sorted(remaining, key=lambda t: (t.priority or 'ZZ', t.index))
        spent = -1
        loe = 0

        for context in p.getContexts():
            m = pDingo.search(context)
            if m:
                cmd = "mysql -N -s -h timesink -u reader -preader timesink -e 'select format(sum(days_worked),2) from entries e join projects p on e.id = p.entry_id where login = \"wasche\" and project_id = {0};'".format(int(m.group(1)))
                n = Popen(cmd, stdout=PIPE, shell=True).stdout.read()
                if n[:4] != 'NULL':
                    spent = float(n)

    	print p, '(', ''.join(p.getContexts()), ')'
        if spent >= 0:
            print "  Progress: {0}/{1} ({2:.0f}%), {3:.2f} days spent".format(len(completed), total, (len(completed) / float(total)) * 100, spent)
        else:
            print "  Progress: {0}/{1} ({2:.0f}%)".format(len(completed), total, (len(completed) / float(total)) * 100)
        print "  Remaining Tasks:"
    	for t in remaining:
    	    print "    {0:02d} {1}".format(t.index, repr(t))
            m = pLOE.search(repr(t))
            if m:
                loe += float(m.group(1))
        if loe > 0:
            print "  Remaining LOE: {0:.2f} days".format(loe)
コード例 #2
0
ファイル: whiny.py プロジェクト: lolindrath/whiny
    def __init__(self, completekey=None, stdin=None, stdout=None):
        #start up the command handling
        cmd.Cmd.__init__(self)
        #start up the ANSI color support 
        init()
        if not os.path.exists(WHINY_PATH):
            os.mkdir(WHINY_PATH)

        self.cur_context = None
        self.cur_project = None

        print "Reading tasks from: ", TODO_FILE
        self.todotxt = TodoTxt()
        self.todotxt.read_tasks(TODO_FILE, DONE_FILE)

        pprint.pprint(self.todotxt.get_contexts())
        pprint.pprint(self.todotxt.get_projects())
コード例 #3
0
ファイル: whiny.py プロジェクト: lolindrath/whiny
class Whiny(cmd.Cmd):
    """ Whiny """

    #Constants

    prompt = "Whiny> "

    def change_prompt(self):
        self.prompt = ""
        if self.cur_project and self.cur_context:
            self.prompt = "%s/%s> " % (self.cur_project, self.cur_context)
        elif self.cur_project and not self.cur_context:
            self.prompt = "%s> " % (self.cur_project)
        elif not self.cur_project and self.cur_context:
            self.prompt = "%s> " % (self.cur_context)
        else:
            self.prompt = "Whiny> "

    def __init__(self, completekey=None, stdin=None, stdout=None):
        #start up the command handling
        cmd.Cmd.__init__(self)
        #start up the ANSI color support 
        init()
        if not os.path.exists(WHINY_PATH):
            os.mkdir(WHINY_PATH)

        self.cur_context = None
        self.cur_project = None

        print "Reading tasks from: ", TODO_FILE
        self.todotxt = TodoTxt()
        self.todotxt.read_tasks(TODO_FILE, DONE_FILE)

        pprint.pprint(self.todotxt.get_contexts())
        pprint.pprint(self.todotxt.get_projects())

    def confirm(self, prompt_str="Confirm", allow_empty=False, default=False):
      fmt = (prompt_str, 'y', 'n') if default else (prompt_str, 'n', 'y')
      if allow_empty:
        prompt = '%s [%s]|%s: ' % fmt
      else:
        prompt = '%s %s|%s: ' % fmt
     
      while True:
        ans = raw_input(prompt).lower()
     
        if ans == '' and allow_empty:
          return default
        elif ans == 'y':
          return True
        elif ans == 'n':
          return False
        else:
          print 'Please enter y or n.'

    def do_cd(self, dir):
        if dir.startswith('@'):
            pass
        elif dir.startswith('+'):
            pass
        elif dir.startswith(".."):
            pass

    def do_add(self, line):
        task = self.todotxt.add(line)
        pprint.pprint(task)
        pass

    def do_rm(self, line):
        # TODO:
        pass

    def do_ls(self, line):
        #TODO: list tasks in current project/context
        #TODO: add searching
        table = Table()
        table.create_table(self.todotxt.get_tasks_table({'done': False, 'waiting': False}))

    def do_waiting(self, line):
        #TODO: list tasks in current project/context
        #TODO: add searching
        table = Table()
        table.create_table(self.todotxt.get_tasks_table({'waiting': True, 'done': False}))

    def do_do(self, line):
        self.do_done(line)
        pass

    def do_done(self, line):
        #TODO: support multiple item #'s
        self.todotxt.mark_done(line)
        pass

    def do_due(self, line):
        #TODO: implement
        pass

    def do_append(self, line):
        #TODO: implement
        pass

    def do_save(self, line):
        print "Saving Tasks..."
        self.todotxt.save(TODO_FILE, DONE_FILE)

    def do_exit(self, line):
        return True

    def do_quit(self, line):
        return True

    def do_EOF(self, line):
        return True

    def postloop(self):
        if self.todotxt.dirty:
            if self.confirm("Do you want to save?", True, True):
                self.do_save("")
        print "Goodbye."