Mercurial > getan
changeset 127:5b334ab7f1b0
Set default encoding
Fixes an issue with the encoding within vim. Using e.g. :read !zeiterfassung always caused
a UnicodeError without setting the encoding.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 13 Feb 2012 13:09:52 +0100 |
parents | 8d533c1b6d23 |
children | 46ed1b94629d |
files | getan/contrib/zeiterfassung.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/getan/contrib/zeiterfassung.py Mon Jan 16 10:13:05 2012 +0100 +++ b/getan/contrib/zeiterfassung.py Mon Feb 13 13:09:52 2012 +0100 @@ -16,6 +16,7 @@ import getopt import re import codecs +import locale from pysqlite2 import dbapi2 as db @@ -193,9 +194,10 @@ if not proj_year: proj_year = date.today().strftime("%Y") - if encoding: - Writer = codecs.getwriter(encoding) - sys.stdout = Writer(sys.stdout) + if not encoding: + encoding = locale.getdefaultlocale()[1] + Writer = codecs.getwriter(encoding) + sys.stdout = Writer(sys.stdout) if not os.path.isfile(database): print >> sys.stderr, "'%s' does not exist or is not a file." % database