##// END OF EJS Templates
Corrected old "python3" syntax key to "python"; added UA header per dpaste TOS
Paul Bissex -
Show More
@@ -20,7 +20,7 b' import re'
20 20 import sys
21 21 import ast
22 22 from itertools import chain
23 from urllib.request import urlopen
23 from urllib.request import Request, urlopen
24 24 from urllib.parse import urlencode
25 25 from pathlib import Path
26 26
@@ -29,6 +29,7 b' from IPython.core.error import TryNext, StdinNotImplementedError, UsageError'
29 29 from IPython.core.macro import Macro
30 30 from IPython.core.magic import Magics, magics_class, line_magic
31 31 from IPython.core.oinspect import find_file, find_source_lines
32 from IPython.core.release import version
32 33 from IPython.testing.skipdoctest import skip_doctest
33 34 from IPython.utils.contexts import preserve_keys
34 35 from IPython.utils.path import get_py_filename
@@ -255,7 +256,7 b' class CodeMagics(Magics):'
255 256
256 257 Options:
257 258
258 -d: Pass a custom description for the gist. The default will say
259 -d: Pass a custom description. The default will say
259 260 "Pasted from IPython".
260 261 """
261 262 opts, args = self.parse_options(parameter_s, 'd:')
@@ -268,11 +269,13 b' class CodeMagics(Magics):'
268 269
269 270 post_data = urlencode({
270 271 "title": opts.get('d', "Pasted from IPython"),
271 "syntax": "python3",
272 "syntax": "python",
272 273 "content": code
273 274 }).encode('utf-8')
274 275
275 response = urlopen("http://dpaste.com/api/v2/", post_data)
276 request = Request("http://dpaste.com/api/v2/",
277 headers={"User-Agent": "IPython v{}".format(version)})
278 response = urlopen(request, post_data)
276 279 return response.headers.get('Location')
277 280
278 281 @line_magic
General Comments 0
You need to be logged in to leave comments. Login now