[Erp5-report] r25939 - /erp5/trunk/products/ERP5/Document/Document.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Mar 10 13:29:52 CET 2009


Author: jerome
Date: Tue Mar 10 13:29:48 2009
New Revision: 25939

URL: http://svn.erp5.org?rev=25939&view=rev
Log:
move _guessEncoding as a class method, and change a bit docstring, as it's no
longer an EmailDocument method.

Modified:
    erp5/trunk/products/ERP5/Document/Document.py

Modified: erp5/trunk/products/ERP5/Document/Document.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Document.py?rev=25939&r1=25938&r2=25939&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Document.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Document.py [utf8] Tue Mar 10 13:29:48 2009
@@ -1273,22 +1273,22 @@
     mime, html = self.convert(**kw)
     return self._stripHTML(str(html))
 
+  def _guessEncoding(self, string):
+    """
+      Try to guess the encoding for this string.
+      Returns None if no encoding can be guessed.
+    """
+    try:
+      import chardet
+    except ImportError:
+      return None
+    return chardet.detect(string).get('encoding', None)
+
   def _stripHTML(self, html, charset=None):
     """
       A private method which can be reused by subclasses
       to strip HTML content
     """
-    def _guessEncoding(self, string):
-      """
-        Some Email Clients indicate wrong encoding
-        This method try to guess which encoding is used.
-      """
-      try:
-        import chardet
-      except ImportError:
-        return None
-      return chardet.detect(string).get('encoding', None)
-
     body_list = re.findall(self.body_parser, str(html))
     if len(body_list):
       stripped_html = body_list[0]




More information about the Erp5-report mailing list