summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 80f79aac5..2402689cc 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -1352,3 +1352,22 @@ def private_ccache(path=None):
if os.path.exists(path):
os.remove(path)
+
+
+if six.PY2:
+ def fsdecode(value):
+ """
+ Decode argument using the file system encoding, as returned by
+ `sys.getfilesystemencoding()`.
+ """
+ if isinstance(value, six.binary_type):
+ return value.decode(sys.getfilesystemencoding())
+ elif isinstance(value, six.text_type):
+ return value
+ else:
+ raise TypeError("expect {0} or {1}, not {2}".format(
+ six.binary_type.__name__,
+ six.text_type.__name__,
+ type(value).__name__))
+else:
+ fsdecode = os.fsdecode #pylint: disable=no-member