comparison configmix/compat.py @ 432:b96f49c9c76b

Proper "repr()" for a jailed configuration: put the root path into the output
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 09 Dec 2021 22:51:10 +0100
parents ce2a8f5a2fb2
children d7f6f2afcee2
comparison
equal deleted inserted replaced
431:49cadb78c45a 432:b96f49c9c76b
13 __all__ = ["PY2", 13 __all__ = ["PY2",
14 "text_to_native_os_str", 14 "text_to_native_os_str",
15 "native_os_str_to_text", 15 "native_os_str_to_text",
16 "u", 16 "u",
17 "u2fs", 17 "u2fs",
18 "uchr"] 18 "uchr",
19 "n"]
19 20
20 21
21 import sys 22 import sys
22 import os 23 import os
23 import locale 24 import locale
69 return s.encode(_FS_ENCODING) 70 return s.encode(_FS_ENCODING)
70 71
71 def uchr(n): 72 def uchr(n):
72 return unichr(n) # noqa: F821 73 return unichr(n) # noqa: F821
73 74
75 def n(s, encoding="utf-8"):
76 if isinstance(s, str):
77 return s
78 else:
79 return s.encode(encoding)
80
74 else: 81 else:
75 82
76 def text_to_native_os_str(s, encoding=None): 83 def text_to_native_os_str(s, encoding=None):
77 return s 84 return s
78 85
101 assert isinstance(s, str) 108 assert isinstance(s, str)
102 return s 109 return s
103 110
104 def uchr(n): 111 def uchr(n):
105 return chr(n) 112 return chr(n)
113
114 def n(s, encoding="utf-8"):
115 if isinstance(s, str):
116 return s
117 else:
118 return s.decode(encoding)