comparison configmix/compat.py @ 16:f85dc4677c01

Implemented the real configuration dictionary with attribute access or variable substitution
author Franz Glasner <hg@dom66.de>
date Thu, 10 Mar 2016 09:39:35 +0100
parents 0b1292e920af
children aa8345dae995
comparison
equal deleted inserted replaced
15:0b1292e920af 16:f85dc4677c01
9 import locale 9 import locale
10 10
11 11
12 __all__ = ["PY2", 12 __all__ = ["PY2",
13 "text_to_native_os_str", 13 "text_to_native_os_str",
14 "native_os_str_to_text"] 14 "native_os_str_to_text",
15 "u"]
15 16
16 17
17 PY2 = sys.version_info[0] <= 2 18 PY2 = sys.version_info[0] <= 2
18 19
19 20
29 30
30 31
31 def native_os_str_to_text(s, encoding=None): 32 def native_os_str_to_text(s, encoding=None):
32 return s.decode(encoding or _OS_ENCODING) 33 return s.decode(encoding or _OS_ENCODING)
33 34
35
36 def u(s, encoding="utf-8"):
37 if isinstance(s, unicode):
38 return s
39 else:
40 return s.decode(encoding)
41
34 else: 42 else:
35 43
36 def text_to_native_os_str(s, encoding=None): 44 def text_to_native_os_str(s, encoding=None):
37 return s 45 return s
38 46
39 47
40 def native_os_str_to_text(s, encoding=None): 48 def native_os_str_to_text(s, encoding=None):
41 return s 49 return s
50
51 def u(s, encoding="utf-8"):
52 if isinstance(s, str):
53 return s
54 else:
55 return s.decode(encoding)