From f25156a6377b89ea34899fb61a94694361a7e511 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 11 Feb 2012 18:23:07 +1300 Subject: Better formatting for headers, help and other key-value displays. We now use proper Columns, rather than laying it out manually. --- libmproxy/console/connview.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'libmproxy/console/connview.py') diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py index 3274a4c9..80750f99 100644 --- a/libmproxy/console/connview.py +++ b/libmproxy/console/connview.py @@ -149,26 +149,23 @@ class ConnectionView(common.WWrap): vals.append(utils.cleanBin( "\n".join(parts[3+parts[2:].index(""):]) )) - kv = common.format_keyvals( + r = [ + urwid.Text(("highlight", "Form data:\n")), + ] + r.extend(common.format_keyvals( zip(keys, vals), key = "header", val = "text" - ) - return [ - urwid.Text(("highlight", "Form data:\n")), - urwid.Text(kv) - ] + )) + return r def _view_conn_urlencoded(self, lines): - return [ - urwid.Text( - common.format_keyvals( - [(k+":", v) for (k, v) in lines], - key = "header", - val = "text" - ) - ) - ] + return common.format_keyvals( + [(k+":", v) for (k, v) in lines], + key = "header", + val = "text" + ) + def _find_pretty_view(self, content, hdrItems): ctype = None @@ -189,19 +186,15 @@ class ConnectionView(common.WWrap): elif ctype and "multipart/form-data" in ctype: boundary = ctype.split('boundary=') if len(boundary) > 1: - return "FOrm data", self._view_conn_formdata(content, boundary[1].split(';')[0]) + return "Form data", self._view_conn_formdata(content, boundary[1].split(';')[0]) return "", self._view_conn_raw(content) def _cached_conn_text(self, e, content, hdrItems, viewmode): - hdr = [] - hdr.extend( - common.format_keyvals( + txt = common.format_keyvals( [(h+":", v) for (h, v) in hdrItems], key = "header", val = "text" ) - ) - txt = [urwid.Text(hdr)] if content: msg = "" if viewmode == common.VIEW_BODY_HEX: -- cgit v1.2.3