Mercurial > getan > getan
diff getan/project.py @ 145:ccd47a2d37a6
Carefully handle non unicode strings for urwid
Urwid seems to have some issues with latin1 and unicode conversion when setting
a text box. Therefore be sure to pass only unicode strings to urwid.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 13 Nov 2012 13:12:12 +0100 |
parents | 5a4946fd9e6d |
children | 8cc1f83d32ee |
line wrap: on
line diff
--- a/getan/project.py Tue Nov 13 13:11:04 2012 +0100 +++ b/getan/project.py Tue Nov 13 13:12:12 2012 +0100 @@ -8,6 +8,8 @@ # This is Free Software licensed unter the terms of GPLv3 or later. # For details see LICENSE coming with the source of 'getan'. +import locale + from datetime import datetime, timedelta class Project(object): @@ -69,6 +71,11 @@ self.end = end self.desc = desc + # carefully handle non unicode string + # urwid seems to have some issue with plain str + if not isinstance(self.desc, unicode): + self.desc = unicode(self.desc, locale.getpreferredencoding()) + def duration(self): return (self.end - self.start)