Diego Búrigo Zacarão  committed 178de37

Dropped is_content arg from detect_encoding function

  • Participants
  • Parent commits 6350811
  • Branches default

Comments (0)

Files changed (1)

 __all__       = ['pofile', 'POFile', 'POEntry', 'mofile', 'MOFile', 'MOEntry',
                  'detect_encoding', 'escape', 'unescape', 'detect_encoding',]
+import os
 import codecs
 import struct
 import textwrap
 # }}}
 # function detect_encoding() {{{
-def detect_encoding(pofile, binary_mode=False, is_content=False):
+def detect_encoding(pofile, binary_mode=False):
     Try to detect the encoding used by the *pofile*. The parameter *pofile*
-    might be a PO file path or its content. In case of using the content, the
-    *is_content* parameter should be set to True. The function will return 
+    might be a PO file path or its content. The function will return 
     polib default *encoding* if it's unable to detect it.
     **Keyword argument**:
       - *pofile*: string, full or relative path to the po/mo file or its content.
-      - *is_contents*: boolean, True if *pofile* has a file content.
       - *binary_mode*: boolean, True if *pofile* has a mo file path.
     >>> print(detect_encoding('tests/test_utf8.po'))
-    >>> print(detect_encoding(open('tests/test_utf8.po','r').read(), is_content=True))
+    >>> print(detect_encoding(open('tests/test_utf8.po','r').read()))
     >>> print(detect_encoding('tests/', True))
     import re
     rx = re.compile(r'"?Content-Type:.+? charset=([\w_\-:\.]+)')
-    if is_content:
+    if not os.path.exists(pofile):
             match =
             if match: