diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-05-26 12:09:39 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-05-26 12:09:39 -0700 |
commit | 22ecd022a84e1c3762dd425bc9bee2230e393d8d (patch) | |
tree | 47f7cac0e86c715bc32e955072fbe59f06d589cf /pathod/utils.py | |
parent | d149c447fe9d3ec359271270ed1c32c2c7da6aad (diff) | |
parent | 92317bc81d72f243095a1bfa192f568637d9bc32 (diff) | |
download | mitmproxy-22ecd022a84e1c3762dd425bc9bee2230e393d8d.tar.gz mitmproxy-22ecd022a84e1c3762dd425bc9bee2230e393d8d.tar.bz2 mitmproxy-22ecd022a84e1c3762dd425bc9bee2230e393d8d.zip |
Merge pull request #1119 from dufferzafar/pathod-port
Python 3 - pathod.utils
Diffstat (limited to 'pathod/utils.py')
-rw-r--r-- | pathod/utils.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/pathod/utils.py b/pathod/utils.py index d1e2dd00..8c6d6290 100644 --- a/pathod/utils.py +++ b/pathod/utils.py @@ -2,6 +2,8 @@ import os import sys import netlib.utils +from netlib.utils import bytes_to_escaped_str + SIZE_UNITS = dict( b=1024 ** 0, @@ -53,24 +55,13 @@ 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 = inner_repr(s) + s = s.replace(b"\r\n", b"PATHOD_MARKER_RN") + s = s.replace(b"\n", b"PATHOD_MARKER_N") + s = bytes_to_escaped_str(s) s = s.replace("PATHOD_MARKER_RN", "\n") s = s.replace("PATHOD_MARKER_N", "\n") return s |