| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,9 +81,7 @@ def loadini(struct, configfile): | |||
| 81 | 81 | "pastebin_confirm": True, | |
| 82 | 82 | "pastebin_expiry": "1week", | |
| 83 | 83 | "pastebin_helper": "", | |
| 84 | - "pastebin_removal_url": "https://bpaste.net/remove/$removal_id", | ||
| 85 | - "pastebin_show_url": "https://bpaste.net/show/$paste_id", | ||
| 86 | - "pastebin_url": "https://bpaste.net/json/new", | ||
| 84 | + "pastebin_url": "https://bpaste.net", | ||
| 87 | 85 | "save_append_py": False, | |
| 88 | 86 | "single_undo_time": 1.0, | |
| 89 | 87 | "syntax": True, | |
@@ -224,8 +222,6 @@ def get_key_no_doublebind(command): | |||
| 224 | 222 | ||
| 225 | 223 | struct.pastebin_confirm = config.getboolean("general", "pastebin_confirm") | |
| 226 | 224 | struct.pastebin_url = config.get("general", "pastebin_url") | |
| 227 | - struct.pastebin_show_url = config.get("general", "pastebin_show_url") | ||
| 228 | - struct.pastebin_removal_url = config.get("general", "pastebin_removal_url") | ||
| 229 | 225 | struct.pastebin_expiry = config.get("general", "pastebin_expiry") | |
| 230 | 226 | struct.pastebin_helper = config.get("general", "pastebin_helper") | |
| 231 | 227 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,35 +40,31 @@ class PasteFailed(Exception): | |||
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | 42 | class PastePinnwand(object): | |
| 43 | - def __init__(self, url, expiry, show_url, removal_url): | ||
| 43 | + def __init__(self, url, expiry): | ||
| 44 | 44 | self.url = url | |
| 45 | 45 | self.expiry = expiry | |
| 46 | - self.show_url = show_url | ||
| 47 | - self.removal_url = removal_url | ||
| 48 | 46 | ||
| 49 | 47 | def paste(self, s): | |
| 50 | 48 | """Upload to pastebin via json interface.""" | |
| 51 | 49 | ||
| 52 | - url = urljoin(self.url, "/json/new") | ||
| 53 | - payload = {"code": s, "lexer": "pycon", "expiry": self.expiry} | ||
| 50 | + url = urljoin(self.url, "/api/v1/paste") | ||
| 51 | + payload = { | ||
| 52 | + "expiry": self.expiry, | ||
| 53 | + "files": [ | ||
| 54 | + {"lexer": "pycon", "content": s} | ||
| 55 | + ], | ||
| 56 | + } | ||
| 54 | 57 | ||
| 55 | 58 | try: | |
| 56 | - response = requests.post(url, data=payload, verify=True) | ||
| 59 | + response = requests.post(url, json=payload, verify=True) | ||
| 57 | 60 | response.raise_for_status() | |
| 58 | 61 | except requests.exceptions.RequestException as exc: | |
| 59 | 62 | raise PasteFailed(exc.message) | |
| 60 | 63 | ||
| 61 | 64 | data = response.json() | |
| 62 | 65 | ||
| 63 | - paste_url_template = Template(self.show_url) | ||
| 64 | - paste_id = urlquote(data["paste_id"]) | ||
| 65 | - paste_url = paste_url_template.safe_substitute(paste_id=paste_id) | ||
| 66 | - | ||
| 67 | - removal_url_template = Template(self.removal_url) | ||
| 68 | - removal_id = urlquote(data["removal_id"]) | ||
| 69 | - removal_url = removal_url_template.safe_substitute( | ||
| 70 | - removal_id=removal_id | ||
| 71 | - ) | ||
| 66 | + paste_url = data["link"] | ||
| 67 | + removal_url = data["removal"] | ||
| 72 | 68 | ||
| 73 | 69 | return (paste_url, removal_url) | |
| 74 | 70 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -477,8 +477,6 @@ def __init__(self, interp, config): | |||
| 477 | 477 | self.paster = PastePinnwand( | |
| 478 | 478 | self.config.pastebin_url, | |
| 479 | 479 | self.config.pastebin_expiry, | |
| 480 | - self.config.pastebin_show_url, | ||
| 481 | - self.config.pastebin_removal_url, | ||
| 482 | 480 | ) | |
| 483 | 481 | ||
| 484 | 482 | @property | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,10 +91,9 @@ pastebin_helper | |||
| 91 | 91 | ^^^^^^^^^^^^^^^ | |
| 92 | 92 | ||
| 93 | 93 | The name of a helper executable that should perform pastebin upload on bpython's | |
| 94 | - behalf. If set, this overrides `pastebin_url`. It also overrides | ||
| 95 | - `pastebin_show_url`, as the helper is expected to return the full URL to the | ||
| 96 | - pastebin as the first word of its output. The data is supplied to the helper via | ||
| 97 | - STDIN. | ||
| 94 | + behalf. If set, this overrides `pastebin_url`. The helper is expected to return | ||
| 95 | + the full URL to the pastebin as the first word of its output. The data is | ||
| 96 | + supplied to the helper via STDIN. | ||
| 98 | 97 | ||
| 99 | 98 | An example helper program is ``pastebinit``, available for most systems. The | |
| 100 | 99 | following helper program can be used to create `gists | |
@@ -141,23 +140,11 @@ following helper program can be used to create `gists | |||
| 141 | 140 | ||
| 142 | 141 | .. versionadded:: 0.12 | |
| 143 | 142 | ||
| 144 | - pastebin_show_url | ||
| 145 | - ^^^^^^^^^^^^^^^^^ | ||
| 146 | - The url under which the new paste can be reached. ``$paste_id`` will be replaced | ||
| 147 | - by the ID of the new paste (default: https://bpaste.net/show/$paste_id/). | ||
| 148 | - | ||
| 149 | - pastebin_removal_url | ||
| 150 | - ^^^^^^^^^^^^^^^^^^^^ | ||
| 151 | - The url under which a paste can be removed. ``$removal_id`` will be replaced by | ||
| 152 | - the removal ID of the paste (default: https://bpaste.net/remova/$removal_id/). | ||
| 153 | - | ||
| 154 | - .. versionadded:: 0.14 | ||
| 155 | - | ||
| 156 | 143 | pastebin_url | |
| 157 | 144 | ^^^^^^^^^^^^ | |
| 158 | 145 | The pastebin url to post to (without a trailing slash). This pastebin has to be | |
| 159 | - a pastebin which uses provides a similar interface to ``bpaste.net``'s JSON | ||
| 160 | - interface (default: https://bpaste.net/json/new). | ||
| 146 | + a pastebin which provides a similar interface to ``bpaste.net``'s JSON | ||
| 147 | + interface (default: https://bpaste.net). | ||
| 161 | 148 | ||
| 162 | 149 | save_append_py | |
| 163 | 150 | ^^^^^^^^^^^^^^ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments