ThirdParty/EditorConfig/editorconfig/compat.py

Tue, 27 Feb 2018 19:56:50 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 27 Feb 2018 19:56:50 +0100
changeset 6161
91456f5321b5
parent 6099
a7fecbc392d7
permissions
-rw-r--r--

Updated editorconfig.

6099
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 """EditorConfig Python2/Python3 compatibility utilities"""
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 import sys
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
6161
91456f5321b5 Updated editorconfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6099
diff changeset
4
6099
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 __all__ = ['force_unicode', 'u']
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 if sys.version_info[0] == 2:
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 text_type = unicode
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 else:
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 text_type = str
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 def force_unicode(string):
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 if not isinstance(string, text_type):
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 string = text_type(string, encoding='utf-8')
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 return string
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 if sys.version_info[0] == 2:
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import codecs
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 u = lambda s: codecs.unicode_escape_decode(s)[0]
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 else:
a7fecbc392d7 Started implementing support for EditorConfig.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 u = lambda s: s

eric ide

mercurial