aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod/utils.py')
-rw-r--r--libpathod/utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/libpathod/utils.py b/libpathod/utils.py
index 1ee50b83..7a1e533f 100644
--- a/libpathod/utils.py
+++ b/libpathod/utils.py
@@ -45,10 +45,24 @@ def xrepr(s):
return repr(s)[1:-1]
+def inner_repr(s):
+ """
+ Returns the inner portion of a string or unicode repr (i.e. without the
+ quotes)
+ """
+ if isinstance(s, unicode):
+ return repr(s)[2:-1]
+ else:
+ return repr(s)[1:-1]
+
+
def escape_unprintables(s):
+ """
+ Like inner_repr, but preserves line breaks.
+ """
s = s.replace("\r\n", "PATHOD_MARKER_RN")
s = s.replace("\n", "PATHOD_MARKER_N")
- s = repr(s)[1:-1]
+ s = inner_repr(s)
s = s.replace("PATHOD_MARKER_RN", "\n")
s = s.replace("PATHOD_MARKER_N", "\n")
return s