Skip to content

Commit f514e8f

Browse files
committed
Bring back do_pastebin() and use the opportunity to factor out some shared code.
1 parent 77c9032 commit f514e8f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

bpython/repl.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,15 @@ def pastebin(self, s=None):
774774
not self.interact.confirm("Pastebin buffer? (y/N) ")):
775775
self.interact.notify("Pastebin aborted")
776776
return
777+
return do_pastebin(s)
778+
779+
780+
def do_pastebin(self, s):
781+
if s == self.prev_pastebin_content:
782+
self.interact.notify('Duplicate pastebin. Previous URL: ' +
783+
self.prev_pastebin_url)
784+
return self.prev_pastebin_url
785+
777786
if self.config.pastebin_helper:
778787
return self.do_pastebin_helper(s)
779788
else:
@@ -788,11 +797,6 @@ def do_pastebin_xmlrpc(self, s):
788797
(self.config.pastebin_url, str(e)))
789798
return
790799

791-
if s == self.prev_pastebin_content:
792-
self.interact.notify('Duplicate pastebin. Previous URL: ' +
793-
self.prev_pastebin_url)
794-
return self.prev_pastebin_url
795-
796800
self.prev_pastebin_content = s
797801

798802
self.interact.notify('Posting data to pastebin...')
@@ -812,11 +816,6 @@ def do_pastebin_xmlrpc(self, s):
812816

813817
def do_pastebin_helper(self, s):
814818
"""Call out to helper program for pastebin upload."""
815-
if s == self.prev_pastebin_content:
816-
self.interact.notify('Duplicate pastebin. Previous URL: ' +
817-
self.prev_pastebin_url)
818-
return self.prev_pastebin_url
819-
820819
self.interact.notify('Posting data to pastebin...')
821820

822821
try:

0 commit comments

Comments
 (0)