comparison scripts/getan-report @ 486:d80f40d239d2

renamed scripts. getan-report and getan-day-report now installed as a script. old script moved to done/contrib
author Magnus Schieder <mschieder@intevation.de>
date Fri, 29 Jun 2018 18:38:55 +0200
parents scripts/getaneval.py@40dd1e33c1dd
children 11d97a40dfa5
comparison
equal deleted inserted replaced
485:726206815059 486:d80f40d239d2
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 #
4 # (c) 2013, 2014 by Björn Ricks <bjoern.ricks@intevation.de>
5 #
6 # This is Free Software licensed under the terms of GPLv3 or later.
7 # For details see LICENSE coming with the source of 'getan'.
8
9 import codecs
10 import locale
11 import sys
12
13 from datetime import date, datetime, timedelta
14 import argparse
15
16 from getan.template import render
17
18
19 def main():
20 usage='getan-get-evaluation [options]'
21 parser = argparse.ArgumentParser(prog='getan', usage=usage)
22
23 parser.add_argument('-d', '--database', dest='database',metavar="DATABASE",
24 help='metavar="DATABASE')
25 parser.add_argument('-t', '--template', dest='template',
26 metavar='TEMPLATE', help='name of getan template')
27 parser.add_argument('-u', '--user', dest='user', help='name of user')
28 parser.add_argument('-p', '--project', dest='project',
29 help='key of output project')
30 parser.add_argument('-w', '--week', type=int, dest='week',
31 help='week of year')
32 parser.add_argument('-y', '--year', type=int, dest='year', help='year')
33 parser.add_argument('-c', '--lastweek', dest='lastweek',
34 help='entries of last working week',
35 action='store_true')
36 parser.add_argument('-m', '--empty', dest='empty',
37 help='show projects without an entries',
38 action="store_true")
39 parser.add_argument('--encoding', dest='encoding',
40 help='encoding of output', metavar='ENCODING')
41
42 args = parser.parse_args()
43
44 if args.lastweek:
45 week = (datetime.now() - timedelta(7)).isocalendar()[1]
46 year = int(date.today().strftime("%Y"))
47 else:
48 year = args.year
49 week = args.week
50
51 template_name = args.template or "wochenbericht"
52
53 if not args.encoding:
54 encoding = locale.getdefaultlocale()[1] or "utf-8"
55
56 sys.stdout = codecs.getwriter(encoding)(sys.stdout.detach())
57
58 user = None
59 if args.user:
60 user = args.user
61
62 print(render(database=args.database, user=user,
63 template=template_name, year=year, week=week,
64 project=args.project, empty_projects=args.empty))
65
66
67 if __name__ == '__main__':
68 main()
69
70 # vim:set ts=4 sw=4 si et sta sts=4 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)