comparison scripts/zeiterfassung.py @ 392:617ced8c7a40

scripts/zeiterfassung.py: enabled choice of used templates.
author Bernhard Reiter <bernhard@intevation.de>
date Mon, 16 Feb 2015 10:21:22 +0100
parents b8cd8751cba0
children
comparison
equal deleted inserted replaced
391:58537062fe74 392:617ced8c7a40
24 24
25 ZEITERFASSUNG_TEMPLATE = "zeiterfassung" 25 ZEITERFASSUNG_TEMPLATE = "zeiterfassung"
26 26
27 USAGE = '''usage: %s <options> 27 USAGE = '''usage: %s <options>
28 with <options> 28 with <options>
29 [--user=|-u <user>] : Name of user, default: $USER 29 [--user=|-u <user>] : Name of user, default: $USER
30 [--database=|-d <database>]: getan database, default: time.db 30 [--database=|-d <database>]: getan database, default: time.db
31 [--project=|-p <key>] : Key of output project, default: all 31 [--project=|-p <key>] : Key of output project, default: all
32 [--encoding=|-e encoding] : encoding of output, default: none 32 [--encoding=|-e encoding] : encoding of output, default: none
33 [--week=]|-w <week>] : week of year 33 [--week=]|-w <week>] : week of year
34 [--year=]|-y <year>] : year 34 [--year=]|-y <year>] : year
35 [--list|-l] : list all projects 35 [--list|-l] : list all projects
36 [--help|-h] : This text 36 [--help|-h] : This text
37 [--emtpy|-m] : show empty projects 37 [--emtpy|-m] : show empty projects
38 [--lastweek|-c] : entries of last working week''' 38 [--lastweek|-c] : entries of last working week
39 [--template|-t <template>] : jinja2 template to use, default: zeiterfassung
40 '''
39 41
40 42
41 def usage(exit_code=0): 43 def usage(exit_code=0):
42 print USAGE % sys.argv[0] 44 print USAGE % sys.argv[0],
43 sys.exit(exit_code) 45 sys.exit(exit_code)
44 46
45 47
46 def main(): 48 def main():
47 49
56 database = None 58 database = None
57 template = ZEITERFASSUNG_TEMPLATE 59 template = ZEITERFASSUNG_TEMPLATE
58 60
59 opts, args = getopt.getopt( 61 opts, args = getopt.getopt(
60 sys.argv[1:], 62 sys.argv[1:],
61 'd:u:p:e:hl:w:y:mc', 63 'd:u:p:e:hl:w:y:mct:',
62 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 64 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=',
63 'year=', 'empty', 'lastweek']) 65 'year=', 'empty', 'lastweek', 'template='])
64 66
65 for opt, val in opts: 67 for opt, val in opts:
66 if opt in ("--database", "-d"): 68 if opt in ("--database", "-d"):
67 database = val 69 database = val
68 elif opt in ("--user", "-u"): 70 elif opt in ("--user", "-u"):
81 week = int(val) 83 week = int(val)
82 elif opt in ("--lastweek", "-c") and not week: 84 elif opt in ("--lastweek", "-c") and not week:
83 week = (datetime.now() - timedelta(7)).isocalendar()[1] 85 week = (datetime.now() - timedelta(7)).isocalendar()[1]
84 elif opt in ("--empty", "-m"): 86 elif opt in ("--empty", "-m"):
85 empty_proj = True 87 empty_proj = True
88 elif opt in ("--template", "-t"):
89 template = val
86 90
87 if not encoding: 91 if not encoding:
88 encoding = locale.getdefaultlocale()[1] 92 encoding = locale.getdefaultlocale()[1]
89 93
90 Writer = codecs.getwriter(encoding) 94 Writer = codecs.getwriter(encoding)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)