Mercurial > kallithea
changeset 1199:268fa0b6b2ef beta
Added os.sep in models for better win support
fixed safe unicode function to not use str as param, and skip execution on unicode
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 02 Apr 2011 21:19:16 +0200 |
parents | 02a7f263a849 |
children | 3ecaa17d9dea |
files | rhodecode/lib/__init__.py rhodecode/model/db.py |
diffstat | 2 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/__init__.py Sat Apr 02 21:12:27 2011 +0200 +++ b/rhodecode/lib/__init__.py Sat Apr 02 21:19:16 2011 +0200 @@ -48,20 +48,23 @@ return hashlib.sha1(username + salt).hexdigest() -def safe_unicode(str): +def safe_unicode(_str): """ safe unicode function. In case of UnicodeDecode error we try to return unicode with errors replace, if this fails we return unicode with string_escape decoding """ + if isinstance(_str, unicode): + return _str + try: - u_str = unicode(str) + u_str = unicode(_str) except UnicodeDecodeError: try: - u_str = unicode(str, 'utf-8', 'replace') + u_str = _str.decode('utf-8', 'replace') except UnicodeDecodeError: #incase we have a decode error just represent as byte string - u_str = unicode(str(str).encode('string_escape')) + u_str = unicode(_str.encode('string_escape')) return u_str
--- a/rhodecode/model/db.py Sat Apr 02 21:12:27 2011 +0200 +++ b/rhodecode/model/db.py Sat Apr 02 21:19:16 2011 +0200 @@ -24,6 +24,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. + +import os import logging import datetime from datetime import date @@ -212,7 +214,7 @@ @property def just_name(self): - return self.repo_name.split('/')[-1] + return self.repo_name.split(os.sep)[-1] @property def groups_with_parents(self):