Show More
@@ -24,7 +24,7 b' Usage' | |||
|
24 | 24 | """ |
|
25 | 25 | |
|
26 | 26 | #----------------------------------------------------------------------------- |
|
27 |
# Copyright (C) 2008 |
|
|
27 | # Copyright (C) 2008 The IPython Development Team | |
|
28 | 28 | # |
|
29 | 29 | # Distributed under the terms of the BSD License. The full license is in |
|
30 | 30 | # the file COPYING, distributed as part of this software. |
@@ -38,9 +38,8 b' import ast' | |||
|
38 | 38 | import re |
|
39 | 39 | |
|
40 | 40 | from IPython.core.magic import Magics, register_magics, line_magic |
|
41 | from IPython.core.plugin import Plugin | |
|
42 | 41 | from IPython.testing.skipdoctest import skip_doctest |
|
43 |
from IPython.utils.traitlets import |
|
|
42 | from IPython.utils.traitlets import Instance | |
|
44 | 43 | |
|
45 | 44 | #----------------------------------------------------------------------------- |
|
46 | 45 | # Definitions of magic functions for use with IPython |
@@ -51,22 +50,12 b' Use activate() on a DirectView object to activate it for magics.' | |||
|
51 | 50 | """ |
|
52 | 51 | |
|
53 | 52 | |
|
54 | class ParallelTricks(Plugin): | |
|
55 | """A component to manage the %result, %px and %autopx magics.""" | |
|
56 | ||
|
57 | active_view = Instance('IPython.parallel.client.view.DirectView') | |
|
58 | verbose = Bool(False, config=True) | |
|
59 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | |
|
60 | ||
|
61 | def __init__(self, shell=None, config=None): | |
|
62 | super(ParallelTricks, self).__init__(shell=shell, config=config) | |
|
63 | self.shell.register_magics(ParallelMagics) | |
|
64 | ||
|
65 | ||
|
66 | 53 | @register_magics |
|
67 | 54 | class ParallelMagics(Magics): |
|
68 | 55 | """A set of magics useful when controlling a parallel IPython cluster. |
|
69 | 56 | """ |
|
57 | active_view = Instance('IPython.parallel.client.view.DirectView') | |
|
58 | ||
|
70 | 59 | def __init__(self, shell): |
|
71 | 60 | super(ParallelMagics, self).__init__(shell) |
|
72 | 61 | # A flag showing if autopx is activated or not |
@@ -242,8 +231,9 b' class ParallelMagics(Magics):' | |||
|
242 | 231 | cell_name = ipself.compile.cache(cell, ipself.execution_count) |
|
243 | 232 | |
|
244 | 233 | try: |
|
245 |
|
|
|
246 |
except (OverflowError, SyntaxError, ValueError, TypeError, |
|
|
234 | ast.parse(cell, filename=cell_name) | |
|
235 | except (OverflowError, SyntaxError, ValueError, TypeError, | |
|
236 | MemoryError): | |
|
247 | 237 | # Case 1 |
|
248 | 238 | ipself.showsyntaxerror() |
|
249 | 239 | ipself.execution_count += 1 |
@@ -317,7 +307,6 b" __doc__ = __doc__.replace('@PX_DOC@'," | |||
|
317 | 307 | __doc__ = __doc__.replace('@RESULT_DOC@', |
|
318 | 308 | " " + ParallelMagics.result.__doc__) |
|
319 | 309 | |
|
320 | ||
|
321 | 310 | _loaded = False |
|
322 | 311 | |
|
323 | 312 | |
@@ -325,6 +314,5 b' def load_ipython_extension(ip):' | |||
|
325 | 314 | """Load the extension in IPython.""" |
|
326 | 315 | global _loaded |
|
327 | 316 | if not _loaded: |
|
328 | plugin = ParallelTricks(shell=ip, config=ip.config) | |
|
329 | ip.plugin_manager.register_plugin('parallelmagic', plugin) | |
|
317 | ip.register_magics(ParallelMagics) | |
|
330 | 318 | _loaded = True |
General Comments 0
You need to be logged in to leave comments.
Login now