From 8f0e4a9bdd29d75ff451002f933d86a09f63dbc8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 29 Mar 2015 15:27:17 +1300 Subject: [PATCH] console: simplify view modes. --- libmproxy/console/flowview.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index c38b9fea3..d4bdb4588 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -154,13 +154,13 @@ class FlowView(urwid.WidgetWrap): ) return (description, text_objects) - def viewmode_get(self, override): + def viewmode_get(self): + override = self.state.get_flow_setting( + self.flow, + (self.state.view_flow_mode, "prettyview") + ) return self.state.default_body_view if override is None else override - def override_get(self): - return self.state.get_flow_setting(self.flow, - (self.state.view_flow_mode, "prettyview")) - def conn_text_raw(self, conn): """ Based on a request/response, conn, returns the elements for @@ -171,8 +171,7 @@ class FlowView(urwid.WidgetWrap): key = "header", val = "text" ) - override = self.override_get() - viewmode = self.viewmode_get(override) + viewmode = self.viewmode_get() msg, body = self.content_view(viewmode, conn) return headers, msg, body @@ -181,26 +180,22 @@ class FlowView(urwid.WidgetWrap): Grabs what is returned by conn_text_raw and merges them all toghether, mainly used by conn_text """ - override = self.override_get() - viewmode = self.viewmode_get(override) - + viewmode = self.viewmode_get() cols = [urwid.Text( [ ("heading", msg), ] ) ] - - if override is not None: - cols.append(urwid.Text([ - " ", - ('heading', "["), - ('heading_key', "m"), - ('heading', (":%s]"%viewmode.name)), - ], - align="right" - ) + cols.append(urwid.Text([ + " ", + ('heading', "["), + ('heading_key', "m"), + ('heading', (":%s]"%viewmode.name)), + ], + align="right" ) + ) title = urwid.AttrWrap(urwid.Columns(cols), "heading") headers.append(title)