# HG changeset patch # User Björn Ricks # Date 1304426638 -7200 # Node ID 9df5d62e6f7e7de68eb6369570970e179cee1e2c # Parent 58bfac26a9ff8d2ee63183bf002f205045d44394 add switch to show also empty projects by default only projects with total_proj time > 0 are displayed diff -r 58bfac26a9ff -r 9df5d62e6f7e contrib/zeiterfassung --- a/contrib/zeiterfassung Tue May 03 14:37:23 2011 +0200 +++ b/contrib/zeiterfassung Tue May 03 14:43:58 2011 +0200 @@ -36,7 +36,8 @@ [--week=]|-w ] : week of year [--year=]|-y ] : year [--list|-l] : list all projects - [--help|-h] : This text''' + [--help|-h] : This text + [--emtpy|-m] : show empty projects''' LIST_PROJECTS = ''' SELECT key, description, active FROM projects @@ -147,11 +148,12 @@ encoding = None week = None year = None + empty_proj = False opts, args = getopt.getopt( sys.argv[1:], - 'd:u:p:e:hl:w:y:', - ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=']) + 'd:u:p:e:hl:w:y:m', + ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=', 'empty']) for opt, val in opts: if opt in ("--database", "-d"): @@ -170,6 +172,8 @@ week = val elif opt in ("--year", "-y"): year = val + elif opt in ("--empty", "-m"): + empty_proj = True if not user: user = os.getenv("USER") @@ -213,7 +217,6 @@ total = 0 for project_id, project, proj_desc in project_ids: - print "# project: %s (%s)" % (project, proj_desc) if not week is None: cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : proj_year}) elif not year: @@ -243,7 +246,9 @@ workpackage, c) total += total_proj - print "# total: %sh\n\n" % human_time(total_proj) + if empty_proj or total_proj > 0: + print "# project: %s (%s)" % (project, proj_desc) + print "# total: %sh\n\n" % human_time(total_proj) print "# total all projects: %sh\n\n" % human_time(total) finally: tolerantClose(cur)