Mercurial > kallithea
diff rhodecode/lib/helpers.py @ 1154:36fe593dfe4b beta
simplified str2bool, and moved safe_unicode out of helpers since it was not html specific function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 18 Mar 2011 19:39:48 +0100 |
parents | fcb5054937f6 |
children | 187a924ed653 |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Fri Mar 18 16:43:36 2011 +0100 +++ b/rhodecode/lib/helpers.py Fri Mar 18 19:39:48 2011 +0100 @@ -8,6 +8,7 @@ import StringIO import urllib +from datetime import datetime from pygments.formatters import HtmlFormatter from pygments import highlight as code_highlight from pylons import url, request, config @@ -38,7 +39,8 @@ from rhodecode.lib import str2bool def _reset(name, value=None, id=NotGiven, type="reset", **attrs): - """Reset button + """ + Reset button """ _set_input_attrs(attrs, type, name, value) _set_id_attr(attrs, id, name) @@ -380,8 +382,6 @@ if not curdate: return '' - from datetime import timedelta, datetime - agescales = [("year", 3600 * 24 * 365), ("month", 3600 * 24 * 30), ("day", 3600 * 24), @@ -671,22 +671,6 @@ list.__init__(self, self.items) -def safe_unicode(str): - """safe unicode function. In case of UnicodeDecode error we try to return - unicode with errors replace, if this failes we return unicode with - string_escape decoding """ - - try: - u_str = unicode(str) - except UnicodeDecodeError: - try: - u_str = unicode(str, 'utf-8', 'replace') - except UnicodeDecodeError: - #incase we have a decode error just represent as byte string - u_str = unicode(str(str).encode('string_escape')) - - return u_str - def changed_tooltip(nodes): if nodes: pref = ': <br/> '