Show More
@@ -21,7 +21,7 b' import sys' | |||
|
21 | 21 | from urllib2 import urlopen |
|
22 | 22 | |
|
23 | 23 | # Our own packages |
|
24 | from IPython.core.error import TryNext, StdinNotImplementedError | |
|
24 | from IPython.core.error import TryNext, StdinNotImplementedError, UsageError | |
|
25 | 25 | from IPython.core.macro import Macro |
|
26 | 26 | from IPython.core.magic import Magics, magics_class, line_magic |
|
27 | 27 | from IPython.core.oinspect import find_file, find_source_lines |
@@ -73,6 +73,8 b' class CodeMagics(Magics):' | |||
|
73 | 73 | """ |
|
74 | 74 | |
|
75 | 75 | opts,args = self.parse_options(parameter_s,'fra',mode='list') |
|
76 | if not args: | |
|
77 | raise UsageError('Missing filename.') | |
|
76 | 78 | raw = 'r' in opts |
|
77 | 79 | force = 'f' in opts |
|
78 | 80 | append = 'a' in opts |
@@ -178,6 +180,9 b' class CodeMagics(Magics):' | |||
|
178 | 180 | %load http://www.example.com/myscript.py |
|
179 | 181 | """ |
|
180 | 182 | opts,args = self.parse_options(arg_s,'y') |
|
183 | if not args: | |
|
184 | raise UsageError('Missing filename, URL, input history range, ' | |
|
185 | 'or macro.') | |
|
181 | 186 | |
|
182 | 187 | contents = self.shell.find_user_code(args) |
|
183 | 188 | l = len(contents) |
@@ -16,6 +16,7 b'' | |||
|
16 | 16 | import os |
|
17 | 17 | |
|
18 | 18 | # Our own packages |
|
19 | from IPython.core.error import UsageError | |
|
19 | 20 | from IPython.core.magic import Magics, magics_class, line_magic |
|
20 | 21 | |
|
21 | 22 | #----------------------------------------------------------------------------- |
@@ -56,14 +57,20 b' class ExtensionMagics(Magics):' | |||
|
56 | 57 | @line_magic |
|
57 | 58 | def load_ext(self, module_str): |
|
58 | 59 | """Load an IPython extension by its module name.""" |
|
60 | if not module_str: | |
|
61 | raise UsageError('Missing module name.') | |
|
59 | 62 | return self.shell.extension_manager.load_extension(module_str) |
|
60 | 63 | |
|
61 | 64 | @line_magic |
|
62 | 65 | def unload_ext(self, module_str): |
|
63 | 66 | """Unload an IPython extension by its module name.""" |
|
67 | if not module_str: | |
|
68 | raise UsageError('Missing module name.') | |
|
64 | 69 | self.shell.extension_manager.unload_extension(module_str) |
|
65 | 70 | |
|
66 | 71 | @line_magic |
|
67 | 72 | def reload_ext(self, module_str): |
|
68 | 73 | """Reload an IPython extension by its module name.""" |
|
74 | if not module_str: | |
|
75 | raise UsageError('Missing module name.') | |
|
69 | 76 | self.shell.extension_manager.reload_extension(module_str) |
@@ -19,7 +19,7 b' import sys' | |||
|
19 | 19 | |
|
20 | 20 | # Our own packages |
|
21 | 21 | from IPython.core import page |
|
22 | from IPython.core.error import StdinNotImplementedError | |
|
22 | from IPython.core.error import StdinNotImplementedError, UsageError | |
|
23 | 23 | from IPython.core.magic import Magics, magics_class, line_magic |
|
24 | 24 | from IPython.testing.skipdoctest import skip_doctest |
|
25 | 25 | from IPython.utils.encoding import DEFAULT_ENCODING |
@@ -92,6 +92,8 b' class NamespaceMagics(Magics):' | |||
|
92 | 92 | @line_magic |
|
93 | 93 | def psource(self, parameter_s='', namespaces=None): |
|
94 | 94 | """Print (or run through pager) the source code for an object.""" |
|
95 | if not parameter_s: | |
|
96 | raise UsageError('Missing object name.') | |
|
95 | 97 | self.shell._inspect('psource',parameter_s, namespaces) |
|
96 | 98 | |
|
97 | 99 | @line_magic |
@@ -681,6 +681,9 b' class OSMagics(Magics):' | |||
|
681 | 681 | %pycat myMacro |
|
682 | 682 | %pycat http://www.example.com/myscript.py |
|
683 | 683 | """ |
|
684 | if not parameter_s: | |
|
685 | raise UsageError('Missing filename, URL, input history range, ' | |
|
686 | 'or macro.') | |
|
684 | 687 | |
|
685 | 688 | try : |
|
686 | 689 | cont = self.shell.find_user_code(parameter_s) |
@@ -30,6 +30,7 b' from IPython.core.interactiveshell import (' | |||
|
30 | 30 | from IPython.core import page |
|
31 | 31 | from IPython.core.autocall import ZMQExitAutocall |
|
32 | 32 | from IPython.core.displaypub import DisplayPublisher |
|
33 | from IPython.core.error import UsageError | |
|
33 | 34 | from IPython.core.magics import MacroToEdit, CodeMagics |
|
34 | 35 | from IPython.core.magic import magics_class, line_magic, Magics |
|
35 | 36 | from IPython.core.payloadpage import install_payload_page |
@@ -349,6 +350,9 b' class KernelMagics(Magics):' | |||
|
349 | 350 | """Show a file through the pager. |
|
350 | 351 | |
|
351 | 352 | Files ending in .py are syntax-highlighted.""" |
|
353 | if not arg_s: | |
|
354 | raise UsageError('Missing filename.') | |
|
355 | ||
|
352 | 356 | cont = open(arg_s).read() |
|
353 | 357 | if arg_s.endswith('.py'): |
|
354 | 358 | cont = self.shell.pycolorize(cont) |
General Comments 0
You need to be logged in to leave comments.
Login now