Show More
@@ -28,6 +28,7 b' import textwrap' | |||
|
28 | 28 | from cStringIO import StringIO |
|
29 | 29 | from getopt import getopt,GetoptError |
|
30 | 30 | from pprint import pformat |
|
31 | from xmlrpclib import ServerProxy | |
|
31 | 32 | |
|
32 | 33 | # cProfile was added in Python2.5 |
|
33 | 34 | try: |
@@ -2072,6 +2073,26 b' Currently the magic system has the following functions:\\n"""' | |||
|
2072 | 2073 | f.write(cmds.encode("utf-8")) |
|
2073 | 2074 | print 'The following commands were written to file `%s`:' % fname |
|
2074 | 2075 | print cmds |
|
2076 | ||
|
2077 | def magic_pastebin(self, parameter_s = ''): | |
|
2078 | """Upload code to the 'Lodge it' paste bin, returning the URL.""" | |
|
2079 | pbserver = ServerProxy('http://paste.pocoo.org/xmlrpc/') | |
|
2080 | code = self.extract_input_lines(parameter_s) | |
|
2081 | if not code: | |
|
2082 | try: | |
|
2083 | codeobj = eval(parameter_s, self.shell.user_ns) | |
|
2084 | except Exception: | |
|
2085 | codeobj = None | |
|
2086 | if isinstance(codeobj, str): | |
|
2087 | code = codeobj | |
|
2088 | elif isinstance(codeobj, Macro): | |
|
2089 | code = codeobj.value | |
|
2090 | else: | |
|
2091 | print parameter_s, ("was not recognised as a history range, nor" | |
|
2092 | " as a string or macro.") | |
|
2093 | return | |
|
2094 | id = pbserver.pastes.newPaste("python", code) | |
|
2095 | return "http://paste.pocoo.org/show/" + id | |
|
2075 | 2096 | |
|
2076 | 2097 | def _edit_macro(self,mname,macro): |
|
2077 | 2098 | """open an editor with the macro data in a file""" |
General Comments 0
You need to be logged in to leave comments.
Login now