Commit bb8cc9f3 authored by Nicolas Delaby's avatar Nicolas Delaby

_guessEncoding is deprecated. Use new method from ERP5Type.Utils


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41212 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a35d359f
...@@ -38,6 +38,7 @@ from Products.ERP5.Document.File import File ...@@ -38,6 +38,7 @@ from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from Products.ERP5.mixin.document_proxy import DocumentProxyMixin, DocumentProxyError from Products.ERP5.mixin.document_proxy import DocumentProxyMixin, DocumentProxyError
from Products.ERP5.Tool.NotificationTool import buildEmailMessage from Products.ERP5.Tool.NotificationTool import buildEmailMessage
from Products.ERP5Type.Utils import guessEncodingFromText
from MethodObject import Method from MethodObject import Method
from zLOG import LOG, INFO from zLOG import LOG, INFO
...@@ -200,7 +201,7 @@ class EmailDocument(TextDocument): ...@@ -200,7 +201,7 @@ class EmailDocument(TextDocument):
else: else:
text = text.decode().encode('utf-8') text = text.decode().encode('utf-8')
except (UnicodeDecodeError, LookupError), error_message: except (UnicodeDecodeError, LookupError), error_message:
encoding = self._guessEncoding(text) encoding = guessEncodingFromText(text, content_type='text/plain')
if encoding is not None: if encoding is not None:
try: try:
text = text.decode(encoding).encode('utf-8') text = text.decode(encoding).encode('utf-8')
...@@ -453,7 +454,8 @@ class EmailDocument(TextDocument): ...@@ -453,7 +454,8 @@ class EmailDocument(TextDocument):
LOG('EmailDocument.getTextContent', INFO, LOG('EmailDocument.getTextContent', INFO,
'Failed to decode %s TEXT message of %s with error: %s' % 'Failed to decode %s TEXT message of %s with error: %s' %
(part_encoding, self.getPath(), error_message)) (part_encoding, self.getPath(), error_message))
codec = self._guessEncoding(message_text) codec = guessEncodingFromText(message_text,
content_type=part.get_content_type())
if codec is not None: if codec is not None:
try: try:
text_result = message_text.decode(codec).encode('utf-8') text_result = message_text.decode(codec).encode('utf-8')
......
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