Mercurial > getan
changeset 46:5f87604ea5ed
add year option for contrib/zeiterfassung
default for year is the current year
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Mon, 07 Feb 2011 11:28:25 +0100 |
parents | f10126519797 |
children | 062ce001abd1 |
files | contrib/zeiterfassung |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/zeiterfassung Wed Dec 15 14:47:40 2010 +0100 +++ b/contrib/zeiterfassung Mon Feb 07 11:28:25 2011 +0100 @@ -57,6 +57,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND (description IS NULL or length(description) = 0) -- trim() function is missing AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) GROUP BY round(julianday(start_time)) @@ -65,6 +66,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND description IS NOT NULL AND length(description) > 0 AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) ORDER BY t @@ -85,6 +87,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND description IS NOT NULL AND length(description) > 0 ''' @@ -124,11 +127,12 @@ project = None encoding = None week = None + year = None opts, args = getopt.getopt( sys.argv[1:], 'd:u:p:e:hl:w:', - ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=']) + ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=']) for opt, val in opts: if opt in ("--database", "-d"): @@ -145,10 +149,15 @@ list_projects = True elif opt in ("--week", "-w"): week = val + elif opt in ("--year", "-y"): + year = val if not user: user = os.getenv("USER") + if not year: + year = date.today().strftime("%Y") + if encoding: Writer = codecs.getwriter(encoding) sys.stdout = Writer(sys.stdout) @@ -185,7 +194,7 @@ 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}) + cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : year}) else: cur.execute(ENTRIES, {'project_id': project_id}) total = 0 @@ -202,6 +211,7 @@ if m: workpackage = m.group(1) c = c[m.end():].strip() + c = c.replace('\x1b', '') print "%s %sh %s %-3s [%s] %s" % ( d.strftime("%d.%m.%Y"), human_time(t),