Upload code to dpaste's paste bin, returning the URL. Usage:\\ %pastebin [-d "Custom description"] 1-7 The argument can be an input history range, a filename, or the name of a string or macro. Options: -d: Pass a custom description for the gist
(self, parameter_s='')
| 244 | |
| 245 | @line_magic |
| 246 | def pastebin(self, parameter_s=''): |
| 247 | """Upload code to dpaste's paste bin, returning the URL. |
| 248 | |
| 249 | Usage:\\ |
| 250 | %pastebin [-d "Custom description"] 1-7 |
| 251 | |
| 252 | The argument can be an input history range, a filename, or the name of a |
| 253 | string or macro. |
| 254 | |
| 255 | Options: |
| 256 | |
| 257 | -d: Pass a custom description for the gist. The default will say |
| 258 | "Pasted from IPython". |
| 259 | """ |
| 260 | opts, args = self.parse_options(parameter_s, 'd:') |
| 261 | |
| 262 | try: |
| 263 | code = self.shell.find_user_code(args) |
| 264 | except (ValueError, TypeError) as e: |
| 265 | print(e.args[0]) |
| 266 | return |
| 267 | |
| 268 | post_data = urlencode({ |
| 269 | "title": opts.get('d', "Pasted from IPython"), |
| 270 | "syntax": "python3", |
| 271 | "content": code |
| 272 | }).encode('utf-8') |
| 273 | |
| 274 | response = urlopen("http://dpaste.com/api/v2/", post_data) |
| 275 | return response.headers.get('Location') |
| 276 | |
| 277 | @line_magic |
| 278 | def loadpy(self, arg_s): |
nothing calls this directly
no test coverage detected