Mercurial > getan
comparison contrib/zeiterfassung @ 60:9df5d62e6f7e
add switch to show also empty projects
by default only projects with total_proj time > 0 are displayed
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 03 May 2011 14:43:58 +0200 |
parents | 58bfac26a9ff |
children | 4b58763e75c1 |
comparison
equal
deleted
inserted
replaced
59:58bfac26a9ff | 60:9df5d62e6f7e |
---|---|
34 [--project=|-p <key>] : Key of output project, default: all | 34 [--project=|-p <key>] : Key of output project, default: all |
35 [--encoding=|-e encoding] : encoding of output, default: none | 35 [--encoding=|-e encoding] : encoding of output, default: none |
36 [--week=]|-w <week>] : week of year | 36 [--week=]|-w <week>] : week of year |
37 [--year=]|-y <year>] : year | 37 [--year=]|-y <year>] : year |
38 [--list|-l] : list all projects | 38 [--list|-l] : list all projects |
39 [--help|-h] : This text''' | 39 [--help|-h] : This text |
40 [--emtpy|-m] : show empty projects''' | |
40 | 41 |
41 LIST_PROJECTS = ''' | 42 LIST_PROJECTS = ''' |
42 SELECT key, description, active FROM projects | 43 SELECT key, description, active FROM projects |
43 ''' | 44 ''' |
44 | 45 |
145 list_projects = False | 146 list_projects = False |
146 project = None | 147 project = None |
147 encoding = None | 148 encoding = None |
148 week = None | 149 week = None |
149 year = None | 150 year = None |
151 empty_proj = False | |
150 | 152 |
151 opts, args = getopt.getopt( | 153 opts, args = getopt.getopt( |
152 sys.argv[1:], | 154 sys.argv[1:], |
153 'd:u:p:e:hl:w:y:', | 155 'd:u:p:e:hl:w:y:m', |
154 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=']) | 156 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=', 'empty']) |
155 | 157 |
156 for opt, val in opts: | 158 for opt, val in opts: |
157 if opt in ("--database", "-d"): | 159 if opt in ("--database", "-d"): |
158 database = val | 160 database = val |
159 elif opt in ("--user", "-u"): | 161 elif opt in ("--user", "-u"): |
168 list_projects = True | 170 list_projects = True |
169 elif opt in ("--week", "-w"): | 171 elif opt in ("--week", "-w"): |
170 week = val | 172 week = val |
171 elif opt in ("--year", "-y"): | 173 elif opt in ("--year", "-y"): |
172 year = val | 174 year = val |
175 elif opt in ("--empty", "-m"): | |
176 empty_proj = True | |
173 | 177 |
174 if not user: | 178 if not user: |
175 user = os.getenv("USER") | 179 user = os.getenv("USER") |
176 | 180 |
177 proj_year = year | 181 proj_year = year |
211 cur.execute(ALL_PROJECT_IDS); | 215 cur.execute(ALL_PROJECT_IDS); |
212 project_ids = cur.fetchall() | 216 project_ids = cur.fetchall() |
213 | 217 |
214 total = 0 | 218 total = 0 |
215 for project_id, project, proj_desc in project_ids: | 219 for project_id, project, proj_desc in project_ids: |
216 print "# project: %s (%s)" % (project, proj_desc) | |
217 if not week is None: | 220 if not week is None: |
218 cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : proj_year}) | 221 cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : proj_year}) |
219 elif not year: | 222 elif not year: |
220 cur.execute(ENTRIES, {'project_id': project_id}) | 223 cur.execute(ENTRIES, {'project_id': project_id}) |
221 else: | 224 else: |
241 TYPE_OF_ENTRY, | 244 TYPE_OF_ENTRY, |
242 user, | 245 user, |
243 workpackage, | 246 workpackage, |
244 c) | 247 c) |
245 total += total_proj | 248 total += total_proj |
246 print "# total: %sh\n\n" % human_time(total_proj) | 249 if empty_proj or total_proj > 0: |
250 print "# project: %s (%s)" % (project, proj_desc) | |
251 print "# total: %sh\n\n" % human_time(total_proj) | |
247 print "# total all projects: %sh\n\n" % human_time(total) | 252 print "# total all projects: %sh\n\n" % human_time(total) |
248 finally: | 253 finally: |
249 tolerantClose(cur) | 254 tolerantClose(cur) |
250 tolerantClose(con) | 255 tolerantClose(con) |
251 | 256 |