Mercurial > getan
comparison contrib/zeiterfassung @ 108:e7548b8c6dcc
Add option to show entries of last week
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 21 Nov 2011 09:22:11 +0100 |
parents | 4b58763e75c1 |
children |
comparison
equal
deleted
inserted
replaced
107:a23e8191c6bc | 108:e7548b8c6dcc |
---|---|
17 import re | 17 import re |
18 import codecs | 18 import codecs |
19 | 19 |
20 from pysqlite2 import dbapi2 as db | 20 from pysqlite2 import dbapi2 as db |
21 | 21 |
22 from datetime import date | 22 from datetime import date, datetime |
23 | 23 |
24 DEFAULT_DATABASE = "time.db" | 24 DEFAULT_DATABASE = "time.db" |
25 | 25 |
26 TYPE_OF_ENTRY = "?" | 26 TYPE_OF_ENTRY = "?" |
27 | 27 |
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 [--emtpy|-m] : show empty projects |
41 [--lastweek|-c] : entries of last working week''' | |
41 | 42 |
42 LIST_PROJECTS = ''' | 43 LIST_PROJECTS = ''' |
43 SELECT key, description, active FROM projects | 44 SELECT key, description, active FROM projects |
44 ''' | 45 ''' |
45 | 46 |
150 year = None | 151 year = None |
151 empty_proj = False | 152 empty_proj = False |
152 | 153 |
153 opts, args = getopt.getopt( | 154 opts, args = getopt.getopt( |
154 sys.argv[1:], | 155 sys.argv[1:], |
155 'd:u:p:e:hl:w:y:m', | 156 'd:u:p:e:hl:w:y:mc', |
156 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=', 'empty']) | 157 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', |
158 'year=', 'empty', 'lastweek']) | |
157 | 159 |
158 for opt, val in opts: | 160 for opt, val in opts: |
159 if opt in ("--database", "-d"): | 161 if opt in ("--database", "-d"): |
160 database = val | 162 database = val |
161 elif opt in ("--user", "-u"): | 163 elif opt in ("--user", "-u"): |
168 usage() | 170 usage() |
169 elif opt in ("--list", "-l"): | 171 elif opt in ("--list", "-l"): |
170 list_projects = True | 172 list_projects = True |
171 elif opt in ("--week", "-w"): | 173 elif opt in ("--week", "-w"): |
172 week = val | 174 week = val |
175 elif opt in ("--lastweek", "-c") and not week: | |
176 currentweek = datetime.now().isocalendar()[1] | |
177 lastweek = currentweek - 1 | |
178 if lastweek <= 0: | |
179 lastweek = 52 | |
180 week = str(lastweek) | |
173 elif opt in ("--year", "-y"): | 181 elif opt in ("--year", "-y"): |
174 year = val | 182 year = val |
175 elif opt in ("--empty", "-m"): | 183 elif opt in ("--empty", "-m"): |
176 empty_proj = True | 184 empty_proj = True |
177 | 185 |