1
#!/usr/bin/env python
2
"""Show a timecard across all projects.
3
4
For printing a chart (the default), pygooglechart is required:
5
6
 http://pygooglechart.slowchop.com/
7
8
Note that this assumes you've got an OS-X style "open" command.  If
9
you don't, it should be easy enough to adapt main to what you need.
10
"""
11
12
import os
13
import sys
14
import exceptions
15
16
import gitaggregates
17
18
def resolve(path):
19
    dotgit = os.path.join(path, ".git")
20
    objects = os.path.join(path, "objects")
21
    if os.path.isdir(dotgit):
22
        return resolve(dotgit)
23
    elif os.path.isdir(objects):
24
        return path
25
    sys.stderr.write("Warning: Can't find a git repo for %s\n" % path)
26
27
if __name__ == '__main__':
28
    th = gitaggregates.TimeHisto()
29
    # Separate log args from repo args
30
    repos = []
31
    log_args = []
32
    current = repos
33
    for a in sys.argv[1:]:
34
        if log_args is current:
35
            log_args.append(a)
36
        else:
37
            if a == '--':
38
                current = log_args
39
            else:
40
                p = resolve(a)
41
                if p:
42
                    repos.append(p)
43
44
    th = gitaggregates.TimeHisto()
45
    for r in repos:
46
        th.add_logs(r, log_args)
47
48
    gitaggregates.open_chart(th)