eric6/ThirdParty/EditorConfig/editorconfig/compat.py

Sun, 14 Apr 2019 15:09:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2019 15:09:21 +0200
changeset 6942
2602857055c5
parent 6161
ThirdParty/EditorConfig/editorconfig/compat.py@91456f5321b5
permissions
-rw-r--r--

Major restructuring of the source tree to get prepared for a setup.py based installation.

"""EditorConfig Python2/Python3 compatibility utilities"""
import sys


__all__ = ['force_unicode', 'u']


if sys.version_info[0] == 2:
    text_type = unicode
else:
    text_type = str


def force_unicode(string):
    if not isinstance(string, text_type):
        string = text_type(string, encoding='utf-8')
    return string


if sys.version_info[0] == 2:
    import codecs
    u = lambda s: codecs.unicode_escape_decode(s)[0]
else:
    u = lambda s: s

eric ide

mercurial