Export to file (p) or clipboard (P)

This commit is contained in:
Shadab Zafar 2016-07-06 23:35:30 +05:30
parent 6119f0f16a
commit 5cf2228250
3 changed files with 25 additions and 14 deletions

View File

@ -284,12 +284,6 @@ def copy_flow_format_data(part, scope, flow):
return data, False return data, False
def export_prompt(k, f):
for exporter in flow.export.EXPORTERS:
if k == exporter[1]:
copy_to_clipboard_or_prompt(exporter[2](f))
def copy_to_clipboard_or_prompt(data): def copy_to_clipboard_or_prompt(data):
# pyperclip calls encode('utf-8') on data to be copied without checking. # pyperclip calls encode('utf-8') on data to be copied without checking.
# if data are already encoded that way UnicodeDecodeError is thrown. # if data are already encoded that way UnicodeDecodeError is thrown.
@ -395,6 +389,18 @@ def ask_save_body(part, master, state, flow):
signals.status_message.send(message="No content to save.") signals.status_message.send(message="No content to save.")
def export_to_clipboard(k, f):
for exporter in flow.export.EXPORTERS:
if k == exporter[1]:
copy_to_clipboard_or_prompt(exporter[2](f))
def export_to_file(k, f):
for exporter in flow.export.EXPORTERS:
if k == exporter[1]:
ask_save_path("File path", exporter[2](f))
flowcache = utils.LRUCache(800) flowcache = utils.LRUCache(800)

View File

@ -17,7 +17,6 @@ def _mkhelp():
("C", "clear flow list or eventlog"), ("C", "clear flow list or eventlog"),
("d", "delete flow"), ("d", "delete flow"),
("D", "duplicate flow"), ("D", "duplicate flow"),
("E", "export"),
("e", "toggle eventlog"), ("e", "toggle eventlog"),
("F", "toggle follow flow list"), ("F", "toggle follow flow list"),
("l", "set limit filter pattern"), ("l", "set limit filter pattern"),
@ -25,7 +24,8 @@ def _mkhelp():
("m", "toggle flow mark"), ("m", "toggle flow mark"),
("M", "toggle marked flow view"), ("M", "toggle marked flow view"),
("n", "create a new request"), ("n", "create a new request"),
("P", "copy flow to clipboard"), ("p", "export flow to file"),
("P", "export flow to clipboard"),
("r", "replay request"), ("r", "replay request"),
("U", "unmark all marked flows"), ("U", "unmark all marked flows"),
("V", "revert changes to request"), ("V", "revert changes to request"),
@ -264,14 +264,20 @@ class ConnectionItem(urwid.WidgetWrap):
callback = self.master.run_script_once, callback = self.master.run_script_once,
args = (self.flow,) args = (self.flow,)
) )
elif key == "P": elif key == "p":
common.ask_copy_part("a", self.flow, self.master, self.state)
elif key == "E":
signals.status_prompt_onekey.send( signals.status_prompt_onekey.send(
self, self,
prompt = "Export", prompt = "Export to file",
keys = [(e[0], e[1]) for e in export.EXPORTERS], keys = [(e[0], e[1]) for e in export.EXPORTERS],
callback = common.export_prompt, callback = common.export_to_file,
args = (self.flow,)
)
elif key == "P":
signals.status_prompt_onekey.send(
self,
prompt = "Export to clipboard",
keys = [(e[0], e[1]) for e in export.EXPORTERS],
callback = common.export_to_clipboard,
args = (self.flow,) args = (self.flow,)
) )
elif key == "b": elif key == "b":

View File

@ -34,7 +34,6 @@ def _mkhelp():
("b", "save request/response body"), ("b", "save request/response body"),
("D", "duplicate flow"), ("D", "duplicate flow"),
("d", "delete flow"), ("d", "delete flow"),
("E", "export"),
("e", "edit request/response"), ("e", "edit request/response"),
("f", "load full body data"), ("f", "load full body data"),
("m", "change body display mode for this entity"), ("m", "change body display mode for this entity"),