Mercurial > kallithea
diff rhodecode/lib/__init__.py @ 1514:87ec80c280bb beta
fixed issues with python2.5
added compat module to rhodecode to have one point of fetching backward incompatible libs.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 07 Oct 2011 02:51:18 +0200 |
parents | a2efbfe84067 |
children | da8f1d1b22de 70e646b2806a |
line wrap: on
line diff
--- a/rhodecode/lib/__init__.py Wed Oct 05 00:10:42 2011 +0200 +++ b/rhodecode/lib/__init__.py Fri Oct 07 02:51:18 2011 +0200 @@ -23,14 +23,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - -try: - import json -except ImportError: - #python 2.5 compatibility - import simplejson as json - - def __get_lem(): from pygments import lexers from string import lower @@ -209,14 +201,14 @@ return unicode_.encode(to_encoding) except UnicodeEncodeError: pass - + try: import chardet encoding = chardet.detect(unicode_)['encoding'] print encoding if encoding is None: raise UnicodeEncodeError() - + return unicode_.encode(encoding) except (ImportError, UnicodeEncodeError): return unicode_.encode(to_encoding, 'replace') @@ -386,4 +378,4 @@ except RepositoryError: from rhodecode.lib.utils import EmptyChangeset cs = EmptyChangeset(requested_revision=rev) - return cs \ No newline at end of file + return cs