Commit cf7f15cf authored by Michael Büsch's avatar Michael Büsch

util: Add helper to clear LANG in environment

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 63b0e506
......@@ -199,3 +199,17 @@ def bytesToHexStr(_bytes):
if _bytes is None:
return None
return binascii.b2a_hex(_bytes).decode("ascii")
def envClearLang(env, lang = "C"):
"""Reset the language settings of an environment dict
to some expected value and return the result.
"""
env = dict(env)
env["LANG"] = lang
for i in {"LANGUAGE", "LC_CTYPE", "LC_NUMERIC",
"LC_TIME", "LC_COLLATE", "LC_MONETARY",
"LC_MESSAGES", "LC_PAPER", "LC_NAME",
"LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT",
"LC_IDENTIFICATION",}:
env.pop(i, None)
return env
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment