From 2880fee4e3f80f8748b6a69f1a72aa3a3a5fa922 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 23 Jul 2012 16:39:25 +1200 Subject: Escape unprintable content in preview. --- libpathod/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libpathod/utils.py') diff --git a/libpathod/utils.py b/libpathod/utils.py index 311d8f77..40f37cab 100644 --- a/libpathod/utils.py +++ b/libpathod/utils.py @@ -41,6 +41,15 @@ def parse_anchor_spec(s): return tuple(s.split("=", 1)) +def escape_unprintables(s): + s = s.replace("\r\n", "PATHOD_MARKER_RN") + s = s.replace("\n", "PATHOD_MARKER_N") + s = repr(s)[1:-1] + s = s.replace("PATHOD_MARKER_RN", "\n") + s = s.replace("PATHOD_MARKER_N", "\n") + return s + + class Data: def __init__(self, name): m = __import__(name) -- cgit v1.2.3