Mercurial > hgrepos > Python > libs > ConfigMix
diff 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 |
line wrap: on
line diff
--- a/configmix/compat.py Thu Dec 09 22:50:26 2021 +0100 +++ b/configmix/compat.py Thu Dec 09 22:51:10 2021 +0100 @@ -15,7 +15,8 @@ "native_os_str_to_text", "u", "u2fs", - "uchr"] + "uchr", + "n"] import sys @@ -71,6 +72,12 @@ def uchr(n): return unichr(n) # noqa: F821 + def n(s, encoding="utf-8"): + if isinstance(s, str): + return s + else: + return s.encode(encoding) + else: def text_to_native_os_str(s, encoding=None): @@ -103,3 +110,9 @@ def uchr(n): return chr(n) + + def n(s, encoding="utf-8"): + if isinstance(s, str): + return s + else: + return s.decode(encoding)
