MCPcopy Index your code
hub / github.com/bpython/bpython / do_pastebin

Method do_pastebin

bpython/repl.py:959–990  ·  view source on GitHub ↗

Actually perform the upload.

(self, s)

Source from the content-addressed store, hash-verified

957 return self.do_pastebin(s)
958
959 def do_pastebin(self, s) -> str | None:
960 """Actually perform the upload."""
961 paste_url: str
962 if s == self.prev_pastebin_content:
963 self.interact.notify(
964 _("Duplicate pastebin. Previous URL: %s. " "Removal URL: %s")
965 % (self.prev_pastebin_url, self.prev_removal_url),
966 10,
967 )
968 return self.prev_pastebin_url
969
970 self.interact.notify(_("Posting data to pastebin..."))
971 try:
972 paste_url, removal_url = self.paster.paste(s)
973 except PasteFailed as e:
974 self.interact.notify(_("Upload failed: %s") % e)
975 return None
976
977 self.prev_pastebin_content = s
978 self.prev_pastebin_url = paste_url
979 self.prev_removal_url = removal_url if removal_url is not None else ""
980
981 if removal_url is not None:
982 self.interact.notify(
983 _("Pastebin URL: %s - Removal URL: %s")
984 % (paste_url, removal_url),
985 10,
986 )
987 else:
988 self.interact.notify(_("Pastebin URL: %s") % (paste_url,), 10)
989
990 return paste_url
991
992 def push(self, line, insert_into_history=True) -> bool:
993 """Push a line of code onto the buffer so it can process it all

Callers 1

pastebinMethod · 0.95

Calls 3

_Function · 0.90
notifyMethod · 0.45
pasteMethod · 0.45

Tested by

no test coverage detected