Show More
@@ -2093,6 +2093,24 b' Currently the magic system has the following functions:\\n"""' | |||||
2093 | pbserver = ServerProxy('http://paste.pocoo.org/xmlrpc/') |
|
2093 | pbserver = ServerProxy('http://paste.pocoo.org/xmlrpc/') | |
2094 | id = pbserver.pastes.newPaste("python", code) |
|
2094 | id = pbserver.pastes.newPaste("python", code) | |
2095 | return "http://paste.pocoo.org/show/" + id |
|
2095 | return "http://paste.pocoo.org/show/" + id | |
|
2096 | ||||
|
2097 | def magic_loadpy(self, arg_s): | |||
|
2098 | """Load a .py python script into the GUI console. | |||
|
2099 | ||||
|
2100 | This magic command can either take a local filename or a url:: | |||
|
2101 | ||||
|
2102 | %loadpy myscript.py | |||
|
2103 | %loadpy http://www.example.com/myscript.py | |||
|
2104 | """ | |||
|
2105 | if not arg_s.endswith('.py'): | |||
|
2106 | raise ValueError('%%load only works with .py files: %s' % arg_s) | |||
|
2107 | if arg_s.startswith('http'): | |||
|
2108 | import urllib2 | |||
|
2109 | response = urllib2.urlopen(arg_s) | |||
|
2110 | content = response.read() | |||
|
2111 | else: | |||
|
2112 | content = open(arg_s).read() | |||
|
2113 | self.set_next_input(content) | |||
2096 |
|
2114 | |||
2097 | def _edit_macro(self,mname,macro): |
|
2115 | def _edit_macro(self,mname,macro): | |
2098 | """open an editor with the macro data in a file""" |
|
2116 | """open an editor with the macro data in a file""" |
@@ -575,24 +575,6 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
575 | """Show a basic reference about the GUI console.""" |
|
575 | """Show a basic reference about the GUI console.""" | |
576 | from IPython.core.usage import gui_reference |
|
576 | from IPython.core.usage import gui_reference | |
577 | page.page(gui_reference, auto_html=True) |
|
577 | page.page(gui_reference, auto_html=True) | |
578 |
|
||||
579 | def magic_loadpy(self, arg_s): |
|
|||
580 | """Load a .py python script into the GUI console. |
|
|||
581 |
|
||||
582 | This magic command can either take a local filename or a url:: |
|
|||
583 |
|
||||
584 | %loadpy myscript.py |
|
|||
585 | %loadpy http://www.example.com/myscript.py |
|
|||
586 | """ |
|
|||
587 | if not arg_s.endswith('.py'): |
|
|||
588 | raise ValueError('%%load only works with .py files: %s' % arg_s) |
|
|||
589 | if arg_s.startswith('http'): |
|
|||
590 | import urllib2 |
|
|||
591 | response = urllib2.urlopen(arg_s) |
|
|||
592 | content = response.read() |
|
|||
593 | else: |
|
|||
594 | content = open(arg_s).read() |
|
|||
595 | self.set_next_input(content) |
|
|||
596 |
|
578 | |||
597 | def set_next_input(self, text): |
|
579 | def set_next_input(self, text): | |
598 | """Send the specified text to the frontend to be presented at the next |
|
580 | """Send the specified text to the frontend to be presented at the next |
General Comments 0
You need to be logged in to leave comments.
Login now