Commit 55548745 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

importing once is enough.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42159 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f9e1c44f
......@@ -57,6 +57,15 @@ from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ZCatalog.Lazy import LazyMap
try:
import chardet
except ImportError:
chardet = None
try:
import magic
except ImportError:
magic = None
def simple_decorator(decorator):
"""Decorator to turn simple function into well-behaved decorator
......@@ -3276,14 +3285,6 @@ def guessEncodingFromText(data, content_type='text/html'):
By default python-magic is used
XXX this implementation must migrate to cloudooo
"""
try:
import chardet
except ImportError:
chardet = None
try:
import magic
except ImportError:
magic = None
if chardet is not None and content_type == 'text/html':
# chardet works fine on html document
return chardet.detect(data).get('encoding', None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment