~mabac/launchpad-work-items-tracker/visible-lane-selector

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python
#
# Create a JSON report from a work item database. The structure is the one
# returned by report_tools.assignee_completion()

import optparse, simplejson

import report_tools

#
# main
#

if __name__ == '__main__':
    report_tools.fix_stdouterr()

    # argv parsing
    optparser = optparse.OptionParser()
    optparser.add_option('-d', '--database',
        help='Path to database', dest='database', metavar='PATH')
    optparser.add_option('-t', '--team',
            help='Restrict report to a particular team', dest='team')
    optparser.add_option('-m', '--milestone',
            help='Restrict report to a particular milestone', dest='milestone')
    optparser.add_option('-c', '--config',
        help='Path to configuration file (if given, this can read adjusted trend lines start values)',
        dest='config', metavar='PATH')
    optparser.add_option('-u', '--user', 
        help='Run for this user', dest='user')

    (opts, args) = optparser.parse_args()
    if not opts.database:
        optparser.error('No database given')
    store = report_tools.get_store(opts.database)

    if opts.user and  opts.team:
        optparser.error('team and user options are mutually exclusive')

    # The typing allows polymorphic behavior
    if opts.user:
        opts.team = report_tools.user_string(opts.user)
    elif opts.team:
        opts.team = report_tools.team_string(opts.team)

    if opts.config:
        config = report_tools.load_config(opts.config)
    else:
        config = {}

    json = {}

    # original WI dump
    json["workitems_by_assignee"] = report_tools.assignee_completion(
        store, opts.team, opts.milestone)

    # blueprint data
    json["specs"] = report_tools.spec_information(
        store, config, opts.team, opts.milestone)

    # team data
    json["teams"] = report_tools.team_information(store, opts.team )

    print simplejson.dumps(json, indent=2, sort_keys=True)