changeset 373:82a5dd050436

Allow to set encoding in getan-eval Per default the current locales encoding will be used if no encoding is set via command line switch.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 10 Mar 2014 09:39:07 +0100
parents a805aaed97dd
children 87cb6c55de1c
files getan/contrib/getan-eval.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/getan/contrib/getan-eval.py	Mon Mar 10 09:23:08 2014 +0100
+++ b/getan/contrib/getan-eval.py	Mon Mar 10 09:39:07 2014 +0100
@@ -6,6 +6,10 @@
 # This is Free Software licensed under the terms of GPLv3 or later.
 # For details see LICENSE coming with the source of 'getan'.
 
+import codecs
+import locale
+import sys
+
 from datetime import date, datetime, timedelta
 from optparse import OptionParser
 
@@ -30,6 +34,8 @@
     parser.add_option("-m", "--empty", dest="empty",
                       help="show projects without an entries",
                       action="store_true")
+    parser.add_option("--encoding", dest="encoding",
+                      help="encoding of output", metavar="ENCODING")
 
     (options, args) = parser.parse_args()
 
@@ -42,6 +48,12 @@
 
     template_name = options.template or "wochenbericht"
 
+    if not options.encoding:
+        encoding = locale.getdefaultlocale()[1]
+
+    Writer = codecs.getwriter(encoding)
+    sys.stdout = Writer(sys.stdout)
+
     print render(database=options.database, user=options.user,
                  template=template_name, year=year, week=week,
                  project=options.project, empty_projects=options.empty)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)