From 453436367103dd9deb693da5b5ebb18c2c2c86ce Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 29 Jul 2016 19:54:44 -0700 Subject: [PATCH] add escape_single_quotes=False arg to bytes_to_escaped_str --- netlib/strutils.py | 4 +++- pathod/language/base.py | 8 ++++---- pathod/pathoc.py | 2 +- test/netlib/test_strutils.py | 5 ++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/netlib/strutils.py b/netlib/strutils.py index 8f27ebb74..4a46b6b1f 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -69,7 +69,7 @@ def escape_control_characters(text, keep_spacing=True): return text.translate(trans) -def bytes_to_escaped_str(data, keep_spacing=False): +def bytes_to_escaped_str(data, keep_spacing=False, escape_single_quotes=False): """ Take bytes and return a safe string that can be displayed to the user. @@ -86,6 +86,8 @@ def bytes_to_escaped_str(data, keep_spacing=False): # We always insert a double-quote here so that we get a single-quoted string back # https://stackoverflow.com/questions/29019340/why-does-python-use-different-quotes-for-representing-strings-depending-on-their ret = repr(b'"' + data).lstrip("b")[2:-1] + if not escape_single_quotes: + ret = re.sub(r"(?