source: stamper/bin/stamps@ 9:2457f4022c60

Last change on this file since 9:2457f4022c60 was 3:4eb41ee30ee9, checked in by Borja Lopez <borja@…>, 10 years ago

Renamed calc to stamps (better/proper name for that tool)

  • Property exe set to *
File size: 1.4 KB
RevLine 
[0]1#!/usr/bin/env python
2
3import sys
4from stamper import Stamper
5
6
7def usage(name):
8 msg = """
9 Usage:
10
11 To gather information of recorded times: %(name)s
12
13 Recorded times for a given customer: %(name)s customer
14
15 Detailed times for a given customer: %(name)s customer details
16 """ % {'name': name}
17 print(msg)
18
19
20if __name__ == '__main__':
21
22 s = Stamper()
23 s.load_stamps()
24
25 if len(sys.argv) == 1:
26 totals = s.totals()
27 print('Total times for all customers:')
28 for t in totals:
29 print(' -> %(customer)s: %(total)s' % {'customer': t,
30 'total': totals[t]})
31 elif len(sys.argv) == 2:
32 if sys.argv[1] in s.customers():
33 print('Total time for %(customer)s: %(total)s' % {
34 'customer': sys.argv[1],
35 'total': s.total_by_customer(sys.argv[1])
36 })
37
38 elif len(sys.argv) == 3:
39 if sys.argv[1] in s.customers():
40 print('Detailed time for %(customer)s' % {
41 'customer': sys.argv[1],
42 })
43 details, totals = s.details_by_customer(sys.argv[1])
44 for day in details:
45 print('------ %(day)s ------' % {'day': day})
46 for line in details[day]:
47 print(line)
48 print(' Total: %(total)s' % {'total': totals[day]})
49
50 else:
51 usage(sys.argv[0])
52 sys.exit(1)
Note: See TracBrowser for help on using the repository browser.