Use textwrap.dedent in flow_export.python_code too

This commit is contained in:
Shadab Zafar 2016-02-10 14:13:32 +05:30
parent 5f044d03b7
commit 33c514e2a7

View File

@ -1,5 +1,6 @@
import urllib import urllib
import netlib.http import netlib.http
from textwrap import dedent
def curl_command(flow): def curl_command(flow):
@ -21,16 +22,18 @@ def curl_command(flow):
def python_code(flow): def python_code(flow):
code = """import requests code = dedent("""
import requests
url = '{url}' url = '{url}'
{headers}{params}{data} {headers}{params}{data}
response = requests.request( response = requests.request(
method='{method}', method='{method}',
url=url,{args} url=url,{args}
) )
print(response.text)""" print(response.text)
""").strip()
components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components) components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components)
url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components) url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components)