aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-03-13 22:29:21 +1100
committerAldo Cortesi <aldo@nullcube.com>2015-03-13 22:29:21 +1100
commit87a3c710415878968f2333e1d7bc4adeccc3a9cb (patch)
treed0a098578bad928bf25e24fd55f830b0501feed5
parent468cc81c8a86bf6f304dfebb5858fa15d27c155b (diff)
downloadmitmproxy-87a3c710415878968f2333e1d7bc4adeccc3a9cb.tar.gz
mitmproxy-87a3c710415878968f2333e1d7bc4adeccc3a9cb.tar.bz2
mitmproxy-87a3c710415878968f2333e1d7bc4adeccc3a9cb.zip
Formatting and whitespace
-rw-r--r--libmproxy/console/__init__.py2
-rw-r--r--libmproxy/console/common.py15
-rw-r--r--libmproxy/console/flowlist.py50
3 files changed, 46 insertions, 21 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index 76a2bb48..26c05aaf 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -776,7 +776,7 @@ class ConsoleMaster(flow.FlowMaster):
self.loop = urwid.MainLoop(
self.view,
screen = self.ui,
- input_filter=self.input_filter
+ input_filter = self.input_filter
)
self.view_flowlist()
self.statusbar.redraw()
diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py
index fa21c93e..c0da9bb3 100644
--- a/libmproxy/console/common.py
+++ b/libmproxy/console/common.py
@@ -41,6 +41,8 @@ def highlight_key(s, k):
KEY_MAX = 30
+
+
def format_keyvals(lst, key="key", val="text", indent=0):
"""
Format a list of (key, value) tuples.
@@ -103,10 +105,8 @@ else:
SYMBOL_RETURN = u"<-"
-
def raw_format_flow(f, focus, extended, padding):
f = dict(f)
-
pile = []
req = []
if extended:
@@ -122,7 +122,7 @@ def raw_format_flow(f, focus, extended, padding):
req.append(fcol(SYMBOL_REPLAY, "replay"))
req.append(fcol(f["req_method"], "method"))
- preamble = sum(i[1] for i in req) + len(req) -1
+ preamble = sum(i[1] for i in req) + len(req) - 1
if f["intercepted"] and not f["acked"]:
uc = "intercept"
@@ -348,7 +348,6 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
duration = 0
if f.response.timestamp_end and f.request.timestamp_start:
duration = f.response.timestamp_end - f.request.timestamp_start
- size = f.response.size()
roundtrip = utils.pretty_duration(duration)
d.update(dict(
@@ -362,7 +361,9 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
d["resp_ctype"] = t[0].split(";")[0]
else:
d["resp_ctype"] = ""
- return flowcache.format_flow(tuple(sorted(d.items())), focus, extended, padding)
+ return flowcache.format_flow(
+ tuple(sorted(d.items())), focus, extended, padding
+ )
def int_version(v):
@@ -380,8 +381,8 @@ class WWrap(urwid.WidgetWrap):
if int_version(urwid.__version__) >= 990:
def set_w(self, x):
self._w = x
+
def get_w(self):
return self._w
- w = property(get_w, set_w)
-
+ w = property(get_w, set_w)
diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py
index 9e7c6d69..145331b2 100644
--- a/libmproxy/console/flowlist.py
+++ b/libmproxy/console/flowlist.py
@@ -3,6 +3,7 @@ import urwid
from netlib import http
from . import common
+
def _mkhelp():
text = []
keys = [
@@ -35,6 +36,7 @@ footer = [
('heading_key', "?"), ":help ",
]
+
class EventListBox(urwid.ListBox):
def __init__(self, master):
self.master = master
@@ -60,7 +62,10 @@ class BodyPile(urwid.Pile):
self,
[
FlowListBox(master),
- urwid.Frame(EventListBox(master), header = self.inactive_header)
+ urwid.Frame(
+ EventListBox(master),
+ header = self.inactive_header
+ )
]
)
self.master = master
@@ -80,11 +85,11 @@ class BodyPile(urwid.Pile):
# This is essentially a copypasta from urwid.Pile's keypress handler.
# So much for "closed for modification, but open for extension".
item_rows = None
- if len(size)==2:
- item_rows = self.get_item_rows( size, focus=True )
+ if len(size) == 2:
+ item_rows = self.get_item_rows(size, focus = True)
i = self.widget_list.index(self.focus_item)
- tsize = self.get_item_size(size,i,True,item_rows)
- return self.focus_item.keypress( tsize, key )
+ tsize = self.get_item_size(size, i, True, item_rows)
+ return self.focus_item.keypress(tsize, key)
class ConnectionItem(common.WWrap):
@@ -95,7 +100,11 @@ class ConnectionItem(common.WWrap):
common.WWrap.__init__(self, w)
def get_text(self):
- return common.format_flow(self.flow, self.f, hostheader=self.master.showhost)
+ return common.format_flow(
+ self.flow,
+ self.f,
+ hostheader = self.master.showhost
+ )
def selectable(self):
return True
@@ -125,7 +134,8 @@ class ConnectionItem(common.WWrap):
[i.copy() for i in self.master.state.view],
self.master.killextra, self.master.rheaders,
False, self.master.nopop,
- self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
+ self.master.options.replay_ignore_params,
+ self.master.options.replay_ignore_content,
self.master.options.replay_ignore_payload_params
)
elif k == "t":
@@ -133,7 +143,8 @@ class ConnectionItem(common.WWrap):
[self.flow.copy()],
self.master.killextra, self.master.rheaders,
False, self.master.nopop,
- self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
+ self.master.options.replay_ignore_params,
+ self.master.options.replay_ignore_content,
self.master.options.replay_ignore_payload_params
)
else:
@@ -249,7 +260,7 @@ class FlowListBox(urwid.ListBox):
def get_method_raw(self, k):
if k:
- self.get_url(k)
+ self.get_url(k)
def get_method(self, k):
if k == "e":
@@ -261,8 +272,13 @@ class FlowListBox(urwid.ListBox):
method = i[0].upper()
self.get_url(method)
- def get_url(self,method):
- self.master.prompt("URL:", "http://www.example.com/", self.new_request, method)
+ def get_url(self, method):
+ self.master.prompt(
+ "URL:",
+ "http://www.example.com/",
+ self.new_request,
+ method
+ )
def new_request(self, url, method):
parts = http.parse_url(str(url))
@@ -283,7 +299,11 @@ class FlowListBox(urwid.ListBox):
elif key == "e":
self.master.toggle_eventlog()
elif key == "l":
- self.master.prompt("Limit: ", self.master.state.limit_txt, self.master.set_limit)
+ self.master.prompt(
+ "Limit: ",
+ self.master.state.limit_txt,
+ self.master.set_limit
+ )
elif key == "L":
self.master.path_prompt(
"Load flows: ",
@@ -291,7 +311,11 @@ class FlowListBox(urwid.ListBox):
self.master.load_flows_callback
)
elif key == "n":
- self.master.prompt_onekey("Method", common.METHOD_OPTIONS, self.get_method)
+ self.master.prompt_onekey(
+ "Method",
+ common.METHOD_OPTIONS,
+ self.get_method
+ )
elif key == "F":
self.master.toggle_follow_flows()
elif key == "W":