From 33c514e2a7d0c2458cf7cbd7bcf1ee6762bd24fa Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 10 Feb 2016 14:13:32 +0530 Subject: Use textwrap.dedent in flow_export.python_code too --- libmproxy/flow_export.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'libmproxy') diff --git a/libmproxy/flow_export.py b/libmproxy/flow_export.py index 584b3be4..52145516 100644 --- a/libmproxy/flow_export.py +++ b/libmproxy/flow_export.py @@ -1,5 +1,6 @@ import urllib import netlib.http +from textwrap import dedent def curl_command(flow): @@ -21,16 +22,18 @@ def curl_command(flow): def python_code(flow): - code = """import requests - -url = '{url}' -{headers}{params}{data} -response = requests.request( - method='{method}', - url=url,{args} -) - -print(response.text)""" + code = dedent(""" + import requests + + url = '{url}' + {headers}{params}{data} + response = requests.request( + method='{method}', + url=url,{args} + ) + + print(response.text) + """).strip() components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components) url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components) -- cgit v1.2.3