|
|
|
@ -98,13 +98,21 @@ def getpathenv():
|
|
|
|
|
envPath = set(env.get('PATH', '').split(":")) | bindir
|
|
|
|
|
return ":".join(envPath)
|
|
|
|
|
|
|
|
|
|
#decorator
|
|
|
|
|
|
|
|
|
|
from collections.abc import Iterable
|
|
|
|
|
def _modify_arg(arg):
|
|
|
|
|
if isinstance(arg, bytes):
|
|
|
|
|
return arg.decode("UTF-8")
|
|
|
|
|
elif not isinstance(arg, str) and isinstance(arg, Iterable):
|
|
|
|
|
return [y if not isinstance(y, bytes) else y.decode("UTF-8") for y in arg]
|
|
|
|
|
return arg
|
|
|
|
|
|
|
|
|
|
#decorator: turns bytes args to str, as well as any bytes in iterable args
|
|
|
|
|
def ensure_unicode(func):
|
|
|
|
|
def _ensure_unicode_wrapper(*args, **kwargs):
|
|
|
|
|
args = [x if not isinstance(x, bytes) else x.decode("UTF-8") for x in args]
|
|
|
|
|
args = [_modify_arg(x) for x in args]
|
|
|
|
|
for x in kwargs:
|
|
|
|
|
if isinstance(kwargs[x], bytes):
|
|
|
|
|
kwargs[x] = kwargs[x].decode("UTF-8")
|
|
|
|
|
kwargs[x] = _modify_arg(kwargs[x])
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
return _ensure_unicode_wrapper
|
|
|
|
|
|
|
|
|
|