Mercurial > kallithea
diff pylons_app/lib/indexers/daemon.py @ 443:e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 01 Sep 2010 23:38:03 +0200 |
parents | c59c4d4323e7 |
children | d726f62f886e |
line wrap: on
line diff
--- a/pylons_app/lib/indexers/daemon.py Wed Sep 01 23:32:47 2010 +0200 +++ b/pylons_app/lib/indexers/daemon.py Wed Sep 01 23:38:03 2010 +0200 @@ -36,6 +36,7 @@ import traceback from pylons_app.config.environment import load_environment from pylons_app.model.hg_model import HgModel +from pylons_app.lib.helpers import safe_unicode from whoosh.index import create_in, open_dir from shutil import rmtree from pylons_app.lib.indexers import ANALYZER, INDEX_EXTENSIONS, IDX_LOCATION, \ @@ -77,11 +78,7 @@ fobj = open(path, 'rb') content = fobj.read() fobj.close() - try: - u_content = unicode(content) - except UnicodeDecodeError: - #incase we have a decode error just represent as byte string - u_content = unicode(str(content).encode('string_escape')) + u_content = safe_unicode(content) else: log.debug(' >> %s' % path) #just index file name without it's content