Show More
@@ -212,13 +212,13 b' def get_input_encoding():' | |||
|
212 | 212 | #----------------------------------------------------------------------------- |
|
213 | 213 | |
|
214 | 214 | class InputSplitter(object): |
|
215 | """An object that can accumulate lines of Python source before execution. | |
|
215 | r"""An object that can accumulate lines of Python source before execution. | |
|
216 | 216 | |
|
217 | 217 | This object is designed to be fed python source line-by-line, using |
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
218 | :meth:`push`. It will return on each push whether the currently pushed | |
|
219 | code could be executed already. In addition, it provides a method called | |
|
220 | :meth:`push_accepts_more` that can be used to query whether more input | |
|
221 | can be pushed into a single interactive block. | |
|
222 | 222 | |
|
223 | 223 | This is a simple example of how an interactive terminal-based client can use |
|
224 | 224 | this tool:: |
@@ -131,9 +131,9 b' def get_default_colors():' | |||
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | class SeparateUnicode(Unicode): |
|
134 | """A Unicode subclass to validate separate_in, separate_out, etc. | |
|
134 | r"""A Unicode subclass to validate separate_in, separate_out, etc. | |
|
135 | 135 | |
|
136 | This is a Unicode based trait that converts '0'->'' and '\\n'->'\n'. | |
|
136 | This is a Unicode based trait that converts '0'->'' and ``'\\n'->'\n'``. | |
|
137 | 137 | """ |
|
138 | 138 | |
|
139 | 139 | def validate(self, obj, value): |
@@ -3035,15 +3035,17 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3035 | 3035 | arguments as strings. The number before the / is the session |
|
3036 | 3036 | number: ~n goes n back from the current session. |
|
3037 | 3037 | |
|
3038 | Optional Parameters: | |
|
3039 |
|
|
|
3040 |
|
|
|
3038 | raw : bool, optional | |
|
3039 | By default, the processed input is used. If this is true, the raw | |
|
3040 | input history is used instead. | |
|
3041 | 3041 | |
|
3042 | Note that slices can be called with two notations: | |
|
3042 | Notes | |
|
3043 | ----- | |
|
3043 | 3044 | |
|
3044 | N:M -> standard python form, means including items N...(M-1). | |
|
3045 | Slices can be described with two notations: | |
|
3045 | 3046 | |
|
3046 | N-M -> include items N..M (closed endpoint). | |
|
3047 | * ``N:M`` -> standard python form, means including items N...(M-1). | |
|
3048 | * ``N-M`` -> include items N..M (closed endpoint). | |
|
3047 | 3049 | """ |
|
3048 | 3050 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) |
|
3049 | 3051 | return "\n".join(x for _, _, x in lines) |
@@ -579,24 +579,36 b' class Magics(Configurable):' | |||
|
579 | 579 | def parse_options(self, arg_str, opt_str, *long_opts, **kw): |
|
580 | 580 | """Parse options passed to an argument string. |
|
581 | 581 | |
|
582 |
The interface is similar to that of getopt |
|
|
583 | Struct with the options as keys and the stripped argument string still | |
|
584 | as a string. | |
|
582 | The interface is similar to that of :func:`getopt.getopt`, but it | |
|
583 | returns a :class:`~IPython.utils.struct.Struct` with the options as keys | |
|
584 | and the stripped argument string still as a string. | |
|
585 | 585 | |
|
586 | 586 | arg_str is quoted as a true sys.argv vector by using shlex.split. |
|
587 | 587 | This allows us to easily expand variables, glob files, quote |
|
588 | 588 | arguments, etc. |
|
589 | 589 | |
|
590 | Options: | |
|
591 | -mode: default 'string'. If given as 'list', the argument string is | |
|
592 | returned as a list (split on whitespace) instead of a string. | |
|
590 | Parameters | |
|
591 | ---------- | |
|
592 | ||
|
593 | arg_str : str | |
|
594 | The arguments to parse. | |
|
593 | 595 | |
|
594 | -list_all: put all option values in lists. Normally only options | |
|
596 | opt_str : str | |
|
597 | The options specification. | |
|
598 | ||
|
599 | mode : str, default 'string' | |
|
600 | If given as 'list', the argument string is returned as a list (split | |
|
601 | on whitespace) instead of a string. | |
|
602 | ||
|
603 | list_all : bool, default False | |
|
604 | Put all option values in lists. Normally only options | |
|
595 | 605 | appearing more than once are put in a list. |
|
596 | 606 | |
|
597 | -posix (True): whether to split the input line in POSIX mode or not, | |
|
598 | as per the conventions outlined in the shlex module from the | |
|
599 | standard library.""" | |
|
607 | posix : bool, default True | |
|
608 | Whether to split the input line in POSIX mode or not, as per the | |
|
609 | conventions outlined in the :mod:`shlex` module from the standard | |
|
610 | library. | |
|
611 | """ | |
|
600 | 612 | |
|
601 | 613 | # inject default options at the beginning of the input line |
|
602 | 614 | caller = sys._getframe(1).f_code.co_name |
@@ -51,18 +51,57 b' Inheritance diagram:' | |||
|
51 | 51 | # The full license is in the file COPYING.txt, distributed with this software. |
|
52 | 52 | #----------------------------------------------------------------------------- |
|
53 | 53 | import argparse |
|
54 | import re | |
|
54 | 55 | |
|
55 | 56 | # Our own imports |
|
56 | 57 | from IPython.core.error import UsageError |
|
58 | from IPython.utils.decorators import undoc | |
|
57 | 59 | from IPython.utils.process import arg_split |
|
58 | 60 | from IPython.utils.text import dedent |
|
59 | 61 | |
|
62 | NAME_RE = re.compile(r"[a-zA-Z][a-zA-Z0-9_-]*$") | |
|
63 | ||
|
64 | @undoc | |
|
60 | 65 | class MagicHelpFormatter(argparse.RawDescriptionHelpFormatter): |
|
61 | """ A HelpFormatter which dedents but otherwise preserves indentation. | |
|
66 | """A HelpFormatter with a couple of changes to meet our needs. | |
|
62 | 67 | """ |
|
68 | # Modified to dedent text. | |
|
63 | 69 | def _fill_text(self, text, width, indent): |
|
64 | 70 | return argparse.RawDescriptionHelpFormatter._fill_text(self, dedent(text), width, indent) |
|
65 | 71 | |
|
72 | # Modified to wrap argument placeholders in <> where necessary. | |
|
73 | def _format_action_invocation(self, action): | |
|
74 | if not action.option_strings: | |
|
75 | metavar, = self._metavar_formatter(action, action.dest)(1) | |
|
76 | return metavar | |
|
77 | ||
|
78 | else: | |
|
79 | parts = [] | |
|
80 | ||
|
81 | # if the Optional doesn't take a value, format is: | |
|
82 | # -s, --long | |
|
83 | if action.nargs == 0: | |
|
84 | parts.extend(action.option_strings) | |
|
85 | ||
|
86 | # if the Optional takes a value, format is: | |
|
87 | # -s ARGS, --long ARGS | |
|
88 | else: | |
|
89 | default = action.dest.upper() | |
|
90 | args_string = self._format_args(action, default) | |
|
91 | # IPYTHON MODIFICATION: If args_string is not a plain name, wrap | |
|
92 | # it in <> so it's valid RST. | |
|
93 | if not NAME_RE.match(args_string): | |
|
94 | args_string = "<%s>" % args_string | |
|
95 | for option_string in action.option_strings: | |
|
96 | parts.append('%s %s' % (option_string, args_string)) | |
|
97 | ||
|
98 | return ', '.join(parts) | |
|
99 | ||
|
100 | # Override the default prefix ('usage') to our % magic escape, | |
|
101 | # in a code block. | |
|
102 | def add_usage(self, usage, actions, groups, prefix="::\n\n %"): | |
|
103 | super(MagicHelpFormatter, self).add_usage(usage, actions, groups, prefix) | |
|
104 | ||
|
66 | 105 | class MagicArgumentParser(argparse.ArgumentParser): |
|
67 | 106 | """ An ArgumentParser tweaked for use by IPython magics. |
|
68 | 107 | """ |
@@ -113,15 +152,8 b' def construct_parser(magic_func):' | |||
|
113 | 152 | if result is not None: |
|
114 | 153 | group = result |
|
115 | 154 | |
|
116 | # Replace the starting 'usage: ' with IPython's %. | |
|
117 | help_text = parser.format_help() | |
|
118 | if help_text.startswith('usage: '): | |
|
119 | help_text = help_text.replace('usage: ', '%', 1) | |
|
120 | else: | |
|
121 | help_text = '%' + help_text | |
|
122 | ||
|
123 | 155 | # Replace the magic function's docstring with the full help text. |
|
124 |
magic_func.__doc__ = |
|
|
156 | magic_func.__doc__ = parser.format_help() | |
|
125 | 157 | |
|
126 | 158 | return parser |
|
127 | 159 |
@@ -114,6 +114,7 b' class BasicMagics(Magics):' | |||
|
114 | 114 | Examples |
|
115 | 115 | -------- |
|
116 | 116 | :: |
|
117 | ||
|
117 | 118 | In [1]: %alias_magic t timeit |
|
118 | 119 | Created `%t` as an alias for `%timeit`. |
|
119 | 120 | Created `%%t` as an alias for `%%timeit`. |
@@ -275,7 +275,7 b' class CodeMagics(Magics):' | |||
|
275 | 275 | where source can be a filename, URL, input history range or macro |
|
276 | 276 | |
|
277 | 277 | Options: |
|
278 | -------- | |
|
278 | ||
|
279 | 279 | -r <lines>: Specify lines or ranges of lines to load from the source. |
|
280 | 280 | Ranges could be specified as x-y (x..y) or in python-style x:y |
|
281 | 281 | (x..(y-1)). Both limits x and y can be left blank (meaning the |
@@ -74,44 +74,44 b' def foo(self, args):' | |||
|
74 | 74 | |
|
75 | 75 | |
|
76 | 76 | def test_magic_arguments(): |
|
77 | assert_equal(magic_foo1.__doc__, '%foo1 [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
77 | assert_equal(magic_foo1.__doc__, '::\n\n %foo1 [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
78 | 78 | assert_equal(getattr(magic_foo1, 'argcmd_name', None), None) |
|
79 | 79 | assert_equal(real_name(magic_foo1), 'foo1') |
|
80 | 80 | assert_equal(magic_foo1(None, ''), argparse.Namespace(foo=None)) |
|
81 | 81 | assert hasattr(magic_foo1, 'has_arguments') |
|
82 | 82 | |
|
83 | assert_equal(magic_foo2.__doc__, '%foo2\n\n A docstring.\n') | |
|
83 | assert_equal(magic_foo2.__doc__, '::\n\n %foo2\n\n A docstring.\n') | |
|
84 | 84 | assert_equal(getattr(magic_foo2, 'argcmd_name', None), None) |
|
85 | 85 | assert_equal(real_name(magic_foo2), 'foo2') |
|
86 | 86 | assert_equal(magic_foo2(None, ''), argparse.Namespace()) |
|
87 | 87 | assert hasattr(magic_foo2, 'has_arguments') |
|
88 | 88 | |
|
89 | assert_equal(magic_foo3.__doc__, '%foo3 [-f FOO] [-b BAR] [-z BAZ]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n\nGroup:\n -b BAR, --bar BAR a grouped argument\n\nSecond Group:\n -z BAZ, --baz BAZ another grouped argument\n') | |
|
89 | assert_equal(magic_foo3.__doc__, '::\n\n %foo3 [-f FOO] [-b BAR] [-z BAZ]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n\nGroup:\n -b BAR, --bar BAR a grouped argument\n\nSecond Group:\n -z BAZ, --baz BAZ another grouped argument\n') | |
|
90 | 90 | assert_equal(getattr(magic_foo3, 'argcmd_name', None), None) |
|
91 | 91 | assert_equal(real_name(magic_foo3), 'foo3') |
|
92 | 92 | assert_equal(magic_foo3(None, ''), |
|
93 | 93 | argparse.Namespace(bar=None, baz=None, foo=None)) |
|
94 | 94 | assert hasattr(magic_foo3, 'has_arguments') |
|
95 | 95 | |
|
96 | assert_equal(magic_foo4.__doc__, '%foo4 [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
96 | assert_equal(magic_foo4.__doc__, '::\n\n %foo4 [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
97 | 97 | assert_equal(getattr(magic_foo4, 'argcmd_name', None), None) |
|
98 | 98 | assert_equal(real_name(magic_foo4), 'foo4') |
|
99 | 99 | assert_equal(magic_foo4(None, ''), argparse.Namespace()) |
|
100 | 100 | assert hasattr(magic_foo4, 'has_arguments') |
|
101 | 101 | |
|
102 | assert_equal(magic_foo5.__doc__, '%frobnicate [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
102 | assert_equal(magic_foo5.__doc__, '::\n\n %frobnicate [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
103 | 103 | assert_equal(getattr(magic_foo5, 'argcmd_name', None), 'frobnicate') |
|
104 | 104 | assert_equal(real_name(magic_foo5), 'frobnicate') |
|
105 | 105 | assert_equal(magic_foo5(None, ''), argparse.Namespace(foo=None)) |
|
106 | 106 | assert hasattr(magic_foo5, 'has_arguments') |
|
107 | 107 | |
|
108 | assert_equal(magic_magic_foo.__doc__, '%magic_foo [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
108 | assert_equal(magic_magic_foo.__doc__, '::\n\n %magic_foo [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
109 | 109 | assert_equal(getattr(magic_magic_foo, 'argcmd_name', None), None) |
|
110 | 110 | assert_equal(real_name(magic_magic_foo), 'magic_foo') |
|
111 | 111 | assert_equal(magic_magic_foo(None, ''), argparse.Namespace(foo=None)) |
|
112 | 112 | assert hasattr(magic_magic_foo, 'has_arguments') |
|
113 | 113 | |
|
114 | assert_equal(foo.__doc__, '%foo [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
114 | assert_equal(foo.__doc__, '::\n\n %foo [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
115 | 115 | assert_equal(getattr(foo, 'argcmd_name', None), None) |
|
116 | 116 | assert_equal(real_name(foo), 'foo') |
|
117 | 117 | assert_equal(foo(None, ''), argparse.Namespace(foo=None)) |
@@ -2,7 +2,8 b'' | |||
|
2 | 2 | """ |
|
3 | 3 | ultratb.py -- Spice up your tracebacks! |
|
4 | 4 | |
|
5 |
* |
|
|
5 | **ColorTB** | |
|
6 | ||
|
6 | 7 | I've always found it a bit hard to visually parse tracebacks in Python. The |
|
7 | 8 | ColorTB class is a solution to that problem. It colors the different parts of a |
|
8 | 9 | traceback in a manner similar to what you would expect from a syntax-highlighting |
@@ -13,7 +14,8 b' Installation instructions for ColorTB::' | |||
|
13 | 14 | import sys,ultratb |
|
14 | 15 | sys.excepthook = ultratb.ColorTB() |
|
15 | 16 | |
|
16 |
* |
|
|
17 | **VerboseTB** | |
|
18 | ||
|
17 | 19 | I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds |
|
18 | 20 | of useful info when a traceback occurs. Ping originally had it spit out HTML |
|
19 | 21 | and intended it for CGI programmers, but why should they have all the fun? I |
@@ -68,6 +68,7 b' from IPython.core import magic_arguments' | |||
|
68 | 68 | from IPython.core.magic import Magics, magics_class, cell_magic |
|
69 | 69 | from IPython.utils import py3compat |
|
70 | 70 | from IPython.utils.path import get_ipython_cache_dir |
|
71 | from IPython.utils.text import dedent | |
|
71 | 72 | |
|
72 | 73 | import Cython |
|
73 | 74 | from Cython.Compiler.Errors import CompileError |
@@ -331,9 +332,12 b' class CythonMagics(Magics):' | |||
|
331 | 332 | return html |
|
332 | 333 | |
|
333 | 334 | __doc__ = __doc__.format( |
|
334 | CYTHON_DOC = ' '*8 + CythonMagics.cython.__doc__, | |
|
335 | CYTHON_INLINE_DOC = ' '*8 + CythonMagics.cython_inline.__doc__, | |
|
336 |
CYTHON_ |
|
|
335 | # rST doesn't see the -+ flag as part of an option list, so we | |
|
336 | # hide it from the module-level docstring. | |
|
337 | CYTHON_DOC = dedent(CythonMagics.cython.__doc__\ | |
|
338 | .replace('-+, --cplus','--cplus ')), | |
|
339 | CYTHON_INLINE_DOC = dedent(CythonMagics.cython_inline.__doc__), | |
|
340 | CYTHON_PYXIMPORT_DOC = dedent(CythonMagics.cython_pyximport.__doc__), | |
|
337 | 341 | ) |
|
338 | 342 | |
|
339 | 343 | def load_ipython_extension(ip): |
@@ -55,6 +55,7 b' from IPython.core.magic_arguments import (' | |||
|
55 | 55 | argument, magic_arguments, parse_argstring |
|
56 | 56 | ) |
|
57 | 57 | from IPython.utils.py3compat import unicode_to_str |
|
58 | from IPython.utils.text import dedent | |
|
58 | 59 | |
|
59 | 60 | class OctaveMagicError(oct2py.Oct2PyError): |
|
60 | 61 | pass |
@@ -145,6 +146,8 b' class OctaveMagics(Magics):' | |||
|
145 | 146 | ''' |
|
146 | 147 | Line-level magic that pulls a variable from Octave. |
|
147 | 148 | |
|
149 | :: | |
|
150 | ||
|
148 | 151 | In [18]: _ = %octave x = [1 2; 3 4]; y = 'hello' |
|
149 | 152 | |
|
150 | 153 | In [19]: %octave_pull x y |
@@ -195,7 +198,7 b' class OctaveMagics(Magics):' | |||
|
195 | 198 | def octave(self, line, cell=None, local_ns=None): |
|
196 | 199 | ''' |
|
197 | 200 | Execute code in Octave, and pull some of the results back into the |
|
198 |
Python namespace |
|
|
201 | Python namespace:: | |
|
199 | 202 | |
|
200 | 203 | In [9]: %octave X = [1 2; 3 4]; mean(X) |
|
201 | 204 | Out[9]: array([[ 2., 3.]]) |
@@ -209,9 +212,9 b' class OctaveMagics(Magics):' | |||
|
209 | 212 | |
|
210 | 213 | -2*x^4 - 1*x^3 + 0*x^2 + 1*x^1 + 2 |
|
211 | 214 | |
|
212 | In the notebook, plots are published as the output of the cell, e.g. | |
|
215 | In the notebook, plots are published as the output of the cell, e.g.:: | |
|
213 | 216 | |
|
214 | %octave plot([1 2 3], [4 5 6]) | |
|
217 | %octave plot([1 2 3], [4 5 6]) | |
|
215 | 218 | |
|
216 | 219 | will create a line plot. |
|
217 | 220 | |
@@ -360,9 +363,9 b' class OctaveMagics(Magics):' | |||
|
360 | 363 | |
|
361 | 364 | |
|
362 | 365 | __doc__ = __doc__.format( |
|
363 |
OCTAVE_DOC = |
|
|
364 |
OCTAVE_PUSH_DOC = |
|
|
365 |
OCTAVE_PULL_DOC = |
|
|
366 | OCTAVE_DOC = dedent(OctaveMagics.octave.__doc__), | |
|
367 | OCTAVE_PUSH_DOC = dedent(OctaveMagics.octave_push.__doc__), | |
|
368 | OCTAVE_PULL_DOC = dedent(OctaveMagics.octave_pull.__doc__) | |
|
366 | 369 | ) |
|
367 | 370 | |
|
368 | 371 |
@@ -75,6 +75,7 b' from IPython.core.magic_arguments import (' | |||
|
75 | 75 | from IPython.external.simplegeneric import generic |
|
76 | 76 | from IPython.utils.py3compat import (str_to_unicode, unicode_to_str, PY3, |
|
77 | 77 | unicode_type) |
|
78 | from IPython.utils.text import dedent | |
|
78 | 79 | |
|
79 | 80 | class RInterpreterError(ri.RRuntimeError): |
|
80 | 81 | """An error when running R code in a %%R magic cell.""" |
@@ -679,10 +680,10 b' class RMagics(Magics):' | |||
|
679 | 680 | return self.Rconverter(result, dataframe=False) |
|
680 | 681 | |
|
681 | 682 | __doc__ = __doc__.format( |
|
682 |
R_DOC = |
|
|
683 |
RPUSH_DOC = |
|
|
684 |
RPULL_DOC = |
|
|
685 |
RGET_DOC = |
|
|
683 | R_DOC = dedent(RMagics.R.__doc__), | |
|
684 | RPUSH_DOC = dedent(RMagics.Rpush.__doc__), | |
|
685 | RPULL_DOC = dedent(RMagics.Rpull.__doc__), | |
|
686 | RGET_DOC = dedent(RMagics.Rget.__doc__) | |
|
686 | 687 | ) |
|
687 | 688 | |
|
688 | 689 |
@@ -145,9 +145,11 b' class NotebookHandler(IPythonHandler):' | |||
|
145 | 145 | |
|
146 | 146 | POST creates new notebooks. The server always decides on the notebook name. |
|
147 | 147 | |
|
148 |
POST /api/notebooks/path |
|
|
149 | If content specified, upload a notebook, otherwise start empty. | |
|
150 | POST /api/notebooks/path?copy=OtherNotebook.ipynb : new copy of OtherNotebook in path | |
|
148 | POST /api/notebooks/path | |
|
149 | New untitled notebook in path. If content specified, upload a | |
|
150 | notebook, otherwise start empty. | |
|
151 | POST /api/notebooks/path?copy=OtherNotebook.ipynb | |
|
152 | New copy of OtherNotebook in path | |
|
151 | 153 | """ |
|
152 | 154 | |
|
153 | 155 | if name is not None: |
@@ -171,14 +173,15 b' class NotebookHandler(IPythonHandler):' | |||
|
171 | 173 | def put(self, path='', name=None): |
|
172 | 174 | """Saves the notebook in the location specified by name and path. |
|
173 | 175 | |
|
174 | PUT /api/notebooks/path/Name.ipynb : Save notebook at path/Name.ipynb | |
|
175 | Notebook structure is specified in `content` key of JSON request body. | |
|
176 | If content is not specified, create a new empty notebook. | |
|
177 | PUT /api/notebooks/path/Name.ipynb?copy=OtherNotebook.ipynb : copy OtherNotebook to Name | |
|
176 | PUT is very similar to POST, but the requester specifies the name, | |
|
177 | whereas with POST, the server picks the name. | |
|
178 | 178 | |
|
179 | POST and PUT are basically the same. The only difference: | |
|
180 | ||
|
181 | - with POST, server always picks the name, with PUT the requester does | |
|
179 | PUT /api/notebooks/path/Name.ipynb | |
|
180 | Save notebook at ``path/Name.ipynb``. Notebook structure is specified | |
|
181 | in `content` key of JSON request body. If content is not specified, | |
|
182 | create a new empty notebook. | |
|
183 | PUT /api/notebooks/path/Name.ipynb?copy=OtherNotebook.ipynb | |
|
184 | Copy OtherNotebook to Name | |
|
182 | 185 | """ |
|
183 | 186 | if name is None: |
|
184 | 187 | raise web.HTTPError(400, "Only PUT to full names. Use POST for directories.") |
@@ -133,9 +133,9 b' class ZMQSocketChannel(Thread):' | |||
|
133 | 133 | def stop(self): |
|
134 | 134 | """Stop the channel's event loop and join its thread. |
|
135 | 135 | |
|
136 |
This calls :meth |
|
|
136 | This calls :meth:`~threading.Thread.join` and returns when the thread | |
|
137 | 137 | terminates. :class:`RuntimeError` will be raised if |
|
138 |
:meth |
|
|
138 | :meth:`~threading.Thread.start` is called again. | |
|
139 | 139 | """ |
|
140 | 140 | self.join() |
|
141 | 141 | |
@@ -430,7 +430,7 b' class IOPubChannel(ZMQSocketChannel):' | |||
|
430 | 430 | def flush(self, timeout=1.0): |
|
431 | 431 | """Immediately processes all pending messages on the iopub channel. |
|
432 | 432 | |
|
433 |
Callers should use this method to ensure that :meth |
|
|
433 | Callers should use this method to ensure that :meth:`call_handlers` | |
|
434 | 434 | has been called for all messages that have been received on the |
|
435 | 435 | 0MQ SUB socket of this channel. |
|
436 | 436 |
@@ -102,7 +102,7 b' class KernelClient(LoggingConfigurable, ConnectionFileMixin):' | |||
|
102 | 102 | This will create the channels if they do not exist and then start |
|
103 | 103 | them (their activity runs in a thread). If port numbers of 0 are |
|
104 | 104 | being used (random ports) then you must first call |
|
105 |
:meth |
|
|
105 | :meth:`start_kernel`. If the channels have been stopped and you | |
|
106 | 106 | call this, :class:`RuntimeError` will be raised. |
|
107 | 107 | """ |
|
108 | 108 | if shell: |
@@ -185,8 +185,8 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||
|
185 | 185 | If random ports (port=0) are being used, this method must be called |
|
186 | 186 | before the channels are created. |
|
187 | 187 | |
|
188 |
Parameters |
|
|
189 |
---------- |
|
|
188 | Parameters | |
|
189 | ---------- | |
|
190 | 190 | **kw : optional |
|
191 | 191 | keyword arguments that are passed down to build the kernel_cmd |
|
192 | 192 | and launching the kernel (e.g. Popen kwargs). |
@@ -227,8 +227,8 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||
|
227 | 227 | 2. If that fails, the kernel is shutdown forcibly by sending it |
|
228 | 228 | a signal. |
|
229 | 229 | |
|
230 |
Parameters |
|
|
231 |
---------- |
|
|
230 | Parameters | |
|
231 | ---------- | |
|
232 | 232 | now : bool |
|
233 | 233 | Should the kernel be forcible killed *now*. This skips the |
|
234 | 234 | first, nice shutdown attempt. |
@@ -48,8 +48,8 b' class ParentPollerWindows(Thread):' | |||
|
48 | 48 | """ Create the poller. At least one of the optional parameters must be |
|
49 | 49 | provided. |
|
50 | 50 | |
|
51 |
Parameters |
|
|
52 |
---------- |
|
|
51 | Parameters | |
|
52 | ---------- | |
|
53 | 53 | interrupt_handle : HANDLE (int), optional |
|
54 | 54 | If provided, the program will generate a Ctrl+C event when this |
|
55 | 55 | handle is signaled. |
@@ -527,11 +527,13 b' class Session(Configurable):' | |||
|
527 | 527 | Returns |
|
528 | 528 | ------- |
|
529 | 529 | msg_list : list |
|
530 | The list of bytes objects to be sent with the format: | |
|
531 | [ident1,ident2,...,DELIM,HMAC,p_header,p_parent,p_metadata,p_content, | |
|
532 | buffer1,buffer2,...]. In this list, the p_* entities are | |
|
533 | the packed or serialized versions, so if JSON is used, these | |
|
534 | are utf8 encoded JSON strings. | |
|
530 | The list of bytes objects to be sent with the format:: | |
|
531 | ||
|
532 | [ident1, ident2, ..., DELIM, HMAC, p_header, p_parent, | |
|
533 | p_metadata, p_content, buffer1, buffer2, ...] | |
|
534 | ||
|
535 | In this list, the ``p_*`` entities are the packed or serialized | |
|
536 | versions, so if JSON is used, these are utf8 encoded JSON strings. | |
|
535 | 537 | """ |
|
536 | 538 | content = msg.get('content', {}) |
|
537 | 539 | if content is None: |
@@ -781,8 +783,8 b' class Session(Configurable):' | |||
|
781 | 783 | methods work with full message lists, whereas pack/unpack work with |
|
782 | 784 | the individual message parts in the message list. |
|
783 | 785 | |
|
784 |
Parameters |
|
|
785 |
---------- |
|
|
786 | Parameters | |
|
787 | ---------- | |
|
786 | 788 | msg_list : list of bytes or Message objects |
|
787 | 789 | The list of message parts of the form [HMAC,p_header,p_parent, |
|
788 | 790 | p_metadata,p_content,buffer1,buffer2,...]. |
@@ -197,116 +197,64 b' class KernelMagics(Magics):' | |||
|
197 | 197 | temporary file and will execute the contents of this file when you |
|
198 | 198 | close it (don't forget to save it!). |
|
199 | 199 | |
|
200 | ||
|
201 | 200 | Options: |
|
202 | 201 | |
|
203 | -n <number>: open the editor at a specified line number. By default, | |
|
204 | the IPython editor hook uses the unix syntax 'editor +N filename', but | |
|
205 | you can configure this by providing your own modified hook if your | |
|
206 | favorite editor supports line-number specifications with a different | |
|
207 | syntax. | |
|
208 | ||
|
209 | -p: this will call the editor with the same data as the previous time | |
|
210 | it was used, regardless of how long ago (in your current session) it | |
|
211 | was. | |
|
212 | ||
|
213 | -r: use 'raw' input. This option only applies to input taken from the | |
|
214 | user's history. By default, the 'processed' history is used, so that | |
|
215 | magics are loaded in their transformed version to valid Python. If | |
|
216 | this option is given, the raw input as typed as the command line is | |
|
217 | used instead. When you exit the editor, it will be executed by | |
|
218 | IPython's own processor. | |
|
202 | -n <number> | |
|
203 | Open the editor at a specified line number. By default, the IPython | |
|
204 | editor hook uses the unix syntax 'editor +N filename', but you can | |
|
205 | configure this by providing your own modified hook if your favorite | |
|
206 | editor supports line-number specifications with a different syntax. | |
|
219 | 207 | |
|
220 | -x: do not execute the edited code immediately upon exit. This is | |
|
221 | mainly useful if you are editing programs which need to be called with | |
|
222 | command line arguments, which you can then do using %run. | |
|
208 | -p | |
|
209 | Call the editor with the same data as the previous time it was used, | |
|
210 | regardless of how long ago (in your current session) it was. | |
|
223 | 211 | |
|
212 | -r | |
|
213 | Use 'raw' input. This option only applies to input taken from the | |
|
214 | user's history. By default, the 'processed' history is used, so that | |
|
215 | magics are loaded in their transformed version to valid Python. If | |
|
216 | this option is given, the raw input as typed as the command line is | |
|
217 | used instead. When you exit the editor, it will be executed by | |
|
218 | IPython's own processor. | |
|
224 | 219 | |
|
225 | 220 | Arguments: |
|
226 | 221 | |
|
227 | 222 | If arguments are given, the following possibilites exist: |
|
228 | 223 | |
|
229 | 224 | - The arguments are numbers or pairs of colon-separated numbers (like |
|
230 | 1 4:8 9). These are interpreted as lines of previous input to be | |
|
231 | loaded into the editor. The syntax is the same of the %macro command. | |
|
225 | 1 4:8 9). These are interpreted as lines of previous input to be | |
|
226 | loaded into the editor. The syntax is the same of the %macro command. | |
|
232 | 227 | |
|
233 | 228 | - If the argument doesn't start with a number, it is evaluated as a |
|
234 | variable and its contents loaded into the editor. You can thus edit | |
|
235 | any string which contains python code (including the result of | |
|
236 | previous edits). | |
|
229 | variable and its contents loaded into the editor. You can thus edit | |
|
230 | any string which contains python code (including the result of | |
|
231 | previous edits). | |
|
237 | 232 | |
|
238 | 233 | - If the argument is the name of an object (other than a string), |
|
239 | IPython will try to locate the file where it was defined and open the | |
|
240 | editor at the point where it is defined. You can use `%edit function` | |
|
241 | to load an editor exactly at the point where 'function' is defined, | |
|
242 | edit it and have the file be executed automatically. | |
|
234 | IPython will try to locate the file where it was defined and open the | |
|
235 | editor at the point where it is defined. You can use ``%edit function`` | |
|
236 | to load an editor exactly at the point where 'function' is defined, | |
|
237 | edit it and have the file be executed automatically. | |
|
243 | 238 | |
|
244 | If the object is a macro (see %macro for details), this opens up your | |
|
245 | specified editor with a temporary file containing the macro's data. | |
|
246 | Upon exit, the macro is reloaded with the contents of the file. | |
|
239 | If the object is a macro (see %macro for details), this opens up your | |
|
240 | specified editor with a temporary file containing the macro's data. | |
|
241 | Upon exit, the macro is reloaded with the contents of the file. | |
|
247 | 242 | |
|
248 | Note: opening at an exact line is only supported under Unix, and some | |
|
249 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
|
250 | '+NUMBER' parameter necessary for this feature. Good editors like | |
|
251 | (X)Emacs, vi, jed, pico and joe all do. | |
|
243 | Note: opening at an exact line is only supported under Unix, and some | |
|
244 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
|
245 | '+NUMBER' parameter necessary for this feature. Good editors like | |
|
246 | (X)Emacs, vi, jed, pico and joe all do. | |
|
252 | 247 | |
|
253 | 248 | - If the argument is not found as a variable, IPython will look for a |
|
254 | file with that name (adding .py if necessary) and load it into the | |
|
255 | editor. It will execute its contents with execfile() when you exit, | |
|
256 | loading any code in the file into your interactive namespace. | |
|
249 | file with that name (adding .py if necessary) and load it into the | |
|
250 | editor. It will execute its contents with execfile() when you exit, | |
|
251 | loading any code in the file into your interactive namespace. | |
|
257 | 252 | |
|
258 | After executing your code, %edit will return as output the code you | |
|
259 | typed in the editor (except when it was an existing file). This way | |
|
260 | you can reload the code in further invocations of %edit as a variable, | |
|
261 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of | |
|
262 | the output. | |
|
253 | Unlike in the terminal, this is designed to use a GUI editor, and we do | |
|
254 | not know when it has closed. So the file you edit will not be | |
|
255 | automatically executed or printed. | |
|
263 | 256 | |
|
264 | 257 | Note that %edit is also available through the alias %ed. |
|
265 | ||
|
266 | This is an example of creating a simple function inside the editor and | |
|
267 | then modifying it. First, start up the editor: | |
|
268 | ||
|
269 | In [1]: ed | |
|
270 | Editing... done. Executing edited code... | |
|
271 | Out[1]: 'def foo():n print "foo() was defined in an editing session"n' | |
|
272 | ||
|
273 | We can then call the function foo(): | |
|
274 | ||
|
275 | In [2]: foo() | |
|
276 | foo() was defined in an editing session | |
|
277 | ||
|
278 | Now we edit foo. IPython automatically loads the editor with the | |
|
279 | (temporary) file where foo() was previously defined: | |
|
280 | ||
|
281 | In [3]: ed foo | |
|
282 | Editing... done. Executing edited code... | |
|
283 | ||
|
284 | And if we call foo() again we get the modified version: | |
|
285 | ||
|
286 | In [4]: foo() | |
|
287 | foo() has now been changed! | |
|
288 | ||
|
289 | Here is an example of how to edit a code snippet successive | |
|
290 | times. First we call the editor: | |
|
291 | ||
|
292 | In [5]: ed | |
|
293 | Editing... done. Executing edited code... | |
|
294 | hello | |
|
295 | Out[5]: "print 'hello'n" | |
|
296 | ||
|
297 | Now we call it again with the previous output (stored in _): | |
|
298 | ||
|
299 | In [6]: ed _ | |
|
300 | Editing... done. Executing edited code... | |
|
301 | hello world | |
|
302 | Out[6]: "print 'hello world'n" | |
|
303 | ||
|
304 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
|
305 | ||
|
306 | In [7]: ed _8 | |
|
307 | Editing... done. Executing edited code... | |
|
308 | hello again | |
|
309 | Out[7]: "print 'hello again'n" | |
|
310 | 258 | """ |
|
311 | 259 | |
|
312 | 260 | opts,args = self.parse_options(parameter_s,'prn:') |
@@ -360,13 +360,14 b' class BackgroundJobBase(threading.Thread):' | |||
|
360 | 360 | The derived classes must implement: |
|
361 | 361 | |
|
362 | 362 | - Their own __init__, since the one here raises NotImplementedError. The |
|
363 | derived constructor must call self._init() at the end, to provide common | |
|
364 | initialization. | |
|
363 | derived constructor must call self._init() at the end, to provide common | |
|
364 | initialization. | |
|
365 | 365 | |
|
366 | 366 | - A strform attribute used in calls to __str__. |
|
367 | 367 | |
|
368 | 368 | - A call() method, which will make the actual execution call and must |
|
369 |
return a value to be held in the 'result' field of the job object. |
|
|
369 | return a value to be held in the 'result' field of the job object. | |
|
370 | """ | |
|
370 | 371 | |
|
371 | 372 | # Class constants for status, in string and as numerical codes (when |
|
372 | 373 | # updating jobs lists, we don't want to do string comparisons). This will |
@@ -378,6 +379,10 b' class BackgroundJobBase(threading.Thread):' | |||
|
378 | 379 | stat_dead_c = -1 |
|
379 | 380 | |
|
380 | 381 | def __init__(self): |
|
382 | """Must be implemented in subclasses. | |
|
383 | ||
|
384 | Subclasses must call :meth:`_init` for standard initialisation. | |
|
385 | """ | |
|
381 | 386 | raise NotImplementedError("This class can not be instantiated directly.") |
|
382 | 387 | |
|
383 | 388 | def _init(self): |
@@ -49,22 +49,23 b' class Audio(DisplayObject):' | |||
|
49 | 49 | |
|
50 | 50 | Examples |
|
51 | 51 | -------- |
|
52 | ||
|
53 | # Generate a sound | |
|
54 | import numpy as np | |
|
55 | framerate = 44100 | |
|
56 | t = np.linspace(0,5,framerate*5) | |
|
57 | data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)) | |
|
58 | Audio(data,rate=framerate) | |
|
59 | ||
|
60 | Audio("http://www.nch.com.au/acm/8k16bitpcm.wav") | |
|
61 | Audio(url="http://www.w3schools.com/html/horse.ogg") | |
|
62 | ||
|
63 | Audio('/path/to/sound.wav') | |
|
64 |
Audio( |
|
|
65 | ||
|
66 | Audio(b'RAW_WAV_DATA..) | |
|
67 |
Audio( |
|
|
52 | :: | |
|
53 | ||
|
54 | # Generate a sound | |
|
55 | import numpy as np | |
|
56 | framerate = 44100 | |
|
57 | t = np.linspace(0,5,framerate*5) | |
|
58 | data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)) | |
|
59 | Audio(data,rate=framerate) | |
|
60 | ||
|
61 | Audio("http://www.nch.com.au/acm/8k16bitpcm.wav") # From URL | |
|
62 | Audio(url="http://www.w3schools.com/html/horse.ogg") | |
|
63 | ||
|
64 | Audio('/path/to/sound.wav') # From file | |
|
65 | Audio(filename='/path/to/sound.ogg') | |
|
66 | ||
|
67 | Audio(b'RAW_WAV_DATA..) # From bytes | |
|
68 | Audio(data=b'RAW_WAV_DATA..) | |
|
68 | 69 | |
|
69 | 70 | """ |
|
70 | 71 | _read_flags = 'rb' |
@@ -198,22 +199,21 b' class IFrame(object):' | |||
|
198 | 199 | class YouTubeVideo(IFrame): |
|
199 | 200 | """Class for embedding a YouTube Video in an IPython session, based on its video id. |
|
200 | 201 | |
|
201 | e.g. to embed the video on this page: | |
|
202 | ||
|
203 | http://www.youtube.com/watch?v=foo | |
|
202 | e.g. to embed the video from http://www.youtube.com/watch?v=foo , you would | |
|
203 | do:: | |
|
204 | 204 | |
|
205 | you would do: | |
|
205 | vid = YouTubeVideo("foo") | |
|
206 | display(vid) | |
|
206 | 207 | |
|
207 | vid = YouTubeVideo("foo") | |
|
208 | display(vid) | |
|
208 | To start from 30 seconds:: | |
|
209 | 209 | |
|
210 | To start from 30 seconds: | |
|
210 | vid = YouTubeVideo("abc", start=30) | |
|
211 | display(vid) | |
|
211 | 212 | |
|
212 | vid = YouTubeVideo("abc", start=30) | |
|
213 | display(vid) | |
|
213 | To calculate seconds from time as hours, minutes, seconds use | |
|
214 | :class:`datetime.timedelta`:: | |
|
214 | 215 | |
|
215 | To calculate seconds from time as hours, minutes, seconds use: | |
|
216 | start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds()) | |
|
216 | start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds()) | |
|
217 | 217 | |
|
218 | 218 | Other parameters can be provided as documented at |
|
219 | 219 | https://developers.google.com/youtube/player_parameters#parameter-subheader |
@@ -316,17 +316,15 b' class FileLink(object):' | |||
|
316 | 316 | class FileLinks(FileLink): |
|
317 | 317 | """Class for embedding local file links in an IPython session, based on path |
|
318 | 318 | |
|
319 |
e.g. to embed links to files that were generated in the IPython notebook |
|
|
320 | ||
|
321 | you would do: | |
|
319 | e.g. to embed links to files that were generated in the IPython notebook | |
|
320 | under ``my/data``, you would do:: | |
|
322 | 321 | |
|
323 | local_files = FileLinks("my/data") | |
|
324 | display(local_files) | |
|
322 | local_files = FileLinks("my/data") | |
|
323 | display(local_files) | |
|
325 | 324 | |
|
326 | or in the HTML notebook, just | |
|
327 | ||
|
328 | FileLinks("my/data") | |
|
325 | or in the HTML notebook, just:: | |
|
329 | 326 | |
|
327 | FileLinks("my/data") | |
|
330 | 328 | """ |
|
331 | 329 | def __init__(self, |
|
332 | 330 | path, |
@@ -337,35 +335,38 b' class FileLinks(FileLink):' | |||
|
337 | 335 | notebook_display_formatter=None, |
|
338 | 336 | terminal_display_formatter=None): |
|
339 | 337 | """ |
|
340 | included_suffixes : list of filename suffixes to include when | |
|
341 | formatting output [default: include all files] | |
|
342 | ||
|
343 | See the FileLink (baseclass of LocalDirectory) docstring for | |
|
344 | information on additional parameters. | |
|
345 | ||
|
346 | notebook_display_formatter : func used to format links for display | |
|
347 |
|
|
|
348 | ||
|
349 | terminal_display_formatter : func used to format links for display | |
|
350 | in the terminal. See discussion of formatter function below. | |
|
351 | ||
|
352 | ||
|
353 |
|
|
|
354 | ---------------------------------- | |
|
355 |
|
|
|
356 | f(dirname, fnames, included_suffixes) | |
|
357 | dirname : the name of a directory (a string), | |
|
358 | fnames : a list of the files in that directory | |
|
359 | included_suffixes : a list of the file suffixes that should be | |
|
360 | included in the output (passing None means | |
|
361 | to include all suffixes in the output in | |
|
362 | the built-in formatters) | |
|
363 | ||
|
364 | returns a list of lines that should will be print in the | |
|
365 | notebook (if passing notebook_display_formatter) or the terminal | |
|
366 | (if passing terminal_display_formatter). This function is iterated | |
|
367 | over for each directory in self.path. Default formatters are in | |
|
368 | place, can be passed here to support alternative formatting. | |
|
338 | See :class:`FileLink` for the ``path``, ``url_prefix``, | |
|
339 | ``result_html_prefix`` and ``result_html_suffix`` parameters. | |
|
340 | ||
|
341 | included_suffixes : list | |
|
342 | Filename suffixes to include when formatting output [default: include | |
|
343 | all files] | |
|
344 | ||
|
345 | notebook_display_formatter : function | |
|
346 | Used to format links for display in the notebook. See discussion of | |
|
347 | formatter functions below. | |
|
348 | ||
|
349 | terminal_display_formatter : function | |
|
350 | Used to format links for display in the terminal. See discussion of | |
|
351 | formatter functions below. | |
|
352 | ||
|
353 | Formatter functions must be of the form:: | |
|
354 | ||
|
355 | f(dirname, fnames, included_suffixes) | |
|
356 | ||
|
357 | dirname : str | |
|
358 | The name of a directory | |
|
359 | fnames : list | |
|
360 | The files in that directory | |
|
361 | included_suffixes : list | |
|
362 | The file suffixes that should be included in the output (passing None | |
|
363 | meansto include all suffixes in the output in the built-in formatters) | |
|
364 | ||
|
365 | The function should return a list of lines that will be printed in the | |
|
366 | notebook (if passing notebook_display_formatter) or the terminal (if | |
|
367 | passing terminal_display_formatter). This function is iterated over for | |
|
368 | each directory in self.path. Default formatters are in place, can be | |
|
369 | passed here to support alternative formatting. | |
|
369 | 370 | |
|
370 | 371 | """ |
|
371 | 372 | if isfile(path): |
@@ -49,8 +49,8 b" def passwd(passphrase=None, algorithm='sha1'):" | |||
|
49 | 49 | |
|
50 | 50 | Examples |
|
51 | 51 | -------- |
|
52 |
|
|
|
53 |
|
|
|
52 | >>> passwd('mypassword') | |
|
53 | 'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12' | |
|
54 | 54 | |
|
55 | 55 | """ |
|
56 | 56 | if passphrase is None: |
@@ -89,16 +89,14 b' def passwd_check(hashed_passphrase, passphrase):' | |||
|
89 | 89 | |
|
90 | 90 | Examples |
|
91 | 91 | -------- |
|
92 |
|
|
|
93 | ||
|
94 | In [2]: passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a', | |
|
95 | ...: 'mypassword') | |
|
96 | Out[2]: True | |
|
97 | ||
|
98 | In [3]: passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a', | |
|
99 | ...: 'anotherpassword') | |
|
100 | Out[3]: False | |
|
101 | ||
|
92 | >>> from IPython.lib.security import passwd_check | |
|
93 | >>> passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a', | |
|
94 | ... 'mypassword') | |
|
95 | True | |
|
96 | ||
|
97 | >>> passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a', | |
|
98 | ... 'anotherpassword') | |
|
99 | False | |
|
102 | 100 | """ |
|
103 | 101 | try: |
|
104 | 102 | algorithm, salt, pw_digest = hashed_passphrase.split(':', 2) |
@@ -16,7 +16,7 b' Module containing single call export functions.' | |||
|
16 | 16 | from functools import wraps |
|
17 | 17 | |
|
18 | 18 | from IPython.nbformat.v3.nbbase import NotebookNode |
|
19 |
from IPython. |
|
|
19 | from IPython.utils.decorators import undoc | |
|
20 | 20 | from IPython.utils.py3compat import string_types |
|
21 | 21 | |
|
22 | 22 | from .exporter import Exporter |
@@ -32,18 +32,20 b' from .rst import RSTExporter' | |||
|
32 | 32 | # Classes |
|
33 | 33 | #----------------------------------------------------------------------------- |
|
34 | 34 | |
|
35 | @undoc | |
|
35 | 36 | def DocDecorator(f): |
|
36 | 37 | |
|
37 | 38 | #Set docstring of function |
|
38 | 39 | f.__doc__ = f.__doc__ + """ |
|
39 |
nb : Notebook |
|
|
40 | nb : :class:`~{nbnode_mod}.NotebookNode` | |
|
41 | The notebook to export. | |
|
40 | 42 | config : config (optional, keyword arg) |
|
41 | 43 | User configuration instance. |
|
42 | 44 | resources : dict (optional, keyword arg) |
|
43 | 45 | Resources used in the conversion process. |
|
44 | 46 | |
|
45 | 47 | Returns |
|
46 |
------- |
|
|
48 | ------- | |
|
47 | 49 | tuple- output, resources, exporter_instance |
|
48 | 50 | output : str |
|
49 | 51 | Jinja 2 output. This is the resulting converted notebook. |
@@ -55,8 +57,10 b' def DocDecorator(f):' | |||
|
55 | 57 | to caller because it provides a 'file_extension' property which |
|
56 | 58 | specifies what extension the output should be saved as. |
|
57 | 59 | |
|
60 | Notes | |
|
61 | ----- | |
|
58 | 62 | WARNING: API WILL CHANGE IN FUTURE RELEASES OF NBCONVERT |
|
59 | """ | |
|
63 | """.format(nbnode_mod=NotebookNode.__module__) | |
|
60 | 64 | |
|
61 | 65 | @wraps(f) |
|
62 | 66 | def decorator(*args, **kwargs): |
@@ -92,11 +96,13 b' def export(exporter, nb, **kw):' | |||
|
92 | 96 | """ |
|
93 | 97 | Export a notebook object using specific exporter class. |
|
94 | 98 | |
|
95 | exporter : Exporter class type or instance | |
|
96 | Class type or instance of the exporter that should be used. If the | |
|
97 | method initializes it's own instance of the class, it is ASSUMED that | |
|
98 | the class type provided exposes a constructor (__init__) with the same | |
|
99 | signature as the base Exporter class. | |
|
99 | Parameters | |
|
100 | ---------- | |
|
101 | exporter : class:`~IPython.nbconvert.exporters.exporter.Exporter` class or instance | |
|
102 | Class type or instance of the exporter that should be used. If the | |
|
103 | method initializes it's own instance of the class, it is ASSUMED that | |
|
104 | the class type provided exposes a constructor (``__init__``) with the same | |
|
105 | signature as the base Exporter class. | |
|
100 | 106 | """ |
|
101 | 107 | |
|
102 | 108 | #Check arguments |
@@ -152,6 +158,8 b' def export_by_name(format_name, nb, **kw):' | |||
|
152 | 158 | (Inspect) is used to find the template's corresponding explicit export |
|
153 | 159 | method defined in this module. That method is then called directly. |
|
154 | 160 | |
|
161 | Parameters | |
|
162 | ---------- | |
|
155 | 163 | format_name : str |
|
156 | 164 | Name of the template style to export to. |
|
157 | 165 | """ |
@@ -32,9 +32,6 b' from IPython.utils.traitlets import MetaHasTraits, Unicode, List' | |||
|
32 | 32 | from IPython.utils.importstring import import_item |
|
33 | 33 | from IPython.utils import text, py3compat |
|
34 | 34 | |
|
35 | from IPython.nbconvert import preprocessors as nbpreprocessors | |
|
36 | ||
|
37 | ||
|
38 | 35 | #----------------------------------------------------------------------------- |
|
39 | 36 | # Class |
|
40 | 37 | #----------------------------------------------------------------------------- |
@@ -96,17 +93,20 b' class Exporter(LoggingConfigurable):' | |||
|
96 | 93 | def default_config(self): |
|
97 | 94 | return Config() |
|
98 | 95 | |
|
99 | ||
|
96 | @nbformat.docstring_nbformat_mod | |
|
100 | 97 | def from_notebook_node(self, nb, resources=None, **kw): |
|
101 | 98 | """ |
|
102 | 99 | Convert a notebook from a notebook node instance. |
|
103 | 100 | |
|
104 | 101 | Parameters |
|
105 | 102 | ---------- |
|
106 | nb : Notebook node | |
|
107 | resources : dict (**kw) | |
|
108 | of additional resources that can be accessed read/write by | |
|
109 | preprocessors. | |
|
103 | nb : :class:`~{nbformat_mod}.nbbase.NotebookNode` | |
|
104 | Notebook node | |
|
105 | resources : dict | |
|
106 | Additional resources that can be accessed read/write by | |
|
107 | preprocessors and filters. | |
|
108 | **kw | |
|
109 | Ignored (?) | |
|
110 | 110 | """ |
|
111 | 111 | nb_copy = copy.deepcopy(nb) |
|
112 | 112 | resources = self._init_resources(resources) |
@@ -27,6 +27,7 b' from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Dict, Any' | |||
|
27 | 27 | from IPython.utils.importstring import import_item |
|
28 | 28 | from IPython.utils import py3compat, text |
|
29 | 29 | |
|
30 | from IPython.nbformat.current import docstring_nbformat_mod | |
|
30 | 31 | from IPython.nbconvert import filters |
|
31 | 32 | from .exporter import Exporter |
|
32 | 33 | |
@@ -186,17 +187,19 b' class TemplateExporter(Exporter):' | |||
|
186 | 187 | else: |
|
187 | 188 | self.log.info("Loaded template %s", try_name) |
|
188 | 189 | break |
|
189 | ||
|
190 | ||
|
191 | @docstring_nbformat_mod | |
|
190 | 192 | def from_notebook_node(self, nb, resources=None, **kw): |
|
191 | 193 | """ |
|
192 | 194 | Convert a notebook from a notebook node instance. |
|
193 | 195 | |
|
194 | 196 | Parameters |
|
195 | 197 | ---------- |
|
196 | nb : Notebook node | |
|
197 | resources : dict (**kw) | |
|
198 | of additional resources that can be accessed read/write by | |
|
199 | preprocessors and filters. | |
|
198 | nb : :class:`~{nbformat_mod}.nbbase.NotebookNode` | |
|
199 | Notebook node | |
|
200 | resources : dict | |
|
201 | Additional resources that can be accessed read/write by | |
|
202 | preprocessors and filters. | |
|
200 | 203 | """ |
|
201 | 204 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) |
|
202 | 205 |
@@ -77,7 +77,7 b' nbconvert_flags.update({' | |||
|
77 | 77 | |
|
78 | 78 | |
|
79 | 79 | class NbConvertApp(BaseIPythonApplication): |
|
80 |
"""Application used to convert |
|
|
80 | """Application used to convert from notebook file type (``*.ipynb``)""" | |
|
81 | 81 | |
|
82 | 82 | name = 'ipython-nbconvert' |
|
83 | 83 | aliases = nbconvert_aliases |
@@ -18,8 +18,7 b' def cell_preprocessor(function):' | |||
|
18 | 18 | """ |
|
19 | 19 | Wrap a function to be executed on all cells of a notebook |
|
20 | 20 | |
|
21 | Wrapped Parameters | |
|
22 | ------------------ | |
|
21 | The wrapped function should have these parameters: | |
|
23 | 22 | |
|
24 | 23 | cell : NotebookNode cell |
|
25 | 24 | Notebook cell being processed |
@@ -88,8 +88,8 b' class TestsBase(unittest.TestCase):' | |||
|
88 | 88 | Replace "ii" with "i" in the string "Hiiii" yields "Hii" |
|
89 | 89 | Another replacement cds "Hi" (the desired output) |
|
90 | 90 | |
|
91 |
Parameters |
|
|
92 |
---------- |
|
|
91 | Parameters | |
|
92 | ---------- | |
|
93 | 93 | text : string |
|
94 | 94 | Text to replace in. |
|
95 | 95 | search : string |
@@ -141,8 +141,8 b' class TestsBase(unittest.TestCase):' | |||
|
141 | 141 | Execute a, IPython shell command, listening for both Errors and non-zero |
|
142 | 142 | return codes. |
|
143 | 143 | |
|
144 | PARAMETERS: | |
|
145 |
---------- |
|
|
144 | Parameters | |
|
145 | ---------- | |
|
146 | 146 | parameters : str |
|
147 | 147 | List of parameters to pass to IPython. |
|
148 | 148 | ignore_return_code : optional bool (default False) |
@@ -31,8 +31,8 b' def convert(nb, to_version):' | |||
|
31 | 31 | a v4. Also assumes that all conversions can be made in one step increments |
|
32 | 32 | between major versions and ignores minor revisions. |
|
33 | 33 | |
|
34 | PARAMETERS: | |
|
35 |
---------- |
|
|
34 | Parameters | |
|
35 | ---------- | |
|
36 | 36 | nb : NotebookNode |
|
37 | 37 | to_version : int |
|
38 | 38 | Major revision to convert the notebook to. Can either be an upgrade or |
@@ -30,6 +30,7 b' from IPython.nbformat.v3 import (' | |||
|
30 | 30 | parse_filename, new_metadata, new_author, new_heading_cell, nbformat, |
|
31 | 31 | nbformat_minor, to_notebook_json |
|
32 | 32 | ) |
|
33 | from IPython.nbformat import v3 as _v_latest | |
|
33 | 34 | |
|
34 | 35 | from .reader import reads as reader_reads |
|
35 | 36 | from .reader import versions |
@@ -41,6 +42,16 b' from .convert import convert' | |||
|
41 | 42 | |
|
42 | 43 | current_nbformat = nbformat |
|
43 | 44 | current_nbformat_minor = nbformat_minor |
|
45 | current_nbformat_module = _v_latest.__name__ | |
|
46 | ||
|
47 | def docstring_nbformat_mod(func): | |
|
48 | """Decorator for docstrings referring to classes/functions accessed through | |
|
49 | nbformat.current. | |
|
50 | ||
|
51 | Put {nbformat_mod} in the docstring in place of 'IPython.nbformat.v3'. | |
|
52 | """ | |
|
53 | func.__doc__ = func.__doc__.format(nbformat_mod=current_nbformat_module) | |
|
54 | return func | |
|
44 | 55 | |
|
45 | 56 | |
|
46 | 57 | class NBFormatError(ValueError): |
@@ -1308,9 +1308,10 b' class HTCondorLauncher(BatchSystemLauncher):' | |||
|
1308 | 1308 | this - the mechanism of shebanged scripts means that the python binary will be |
|
1309 | 1309 | launched with argv[0] set to the *location of the ip{cluster, engine, controller} |
|
1310 | 1310 | scripts on the remote node*. This means you need to take care that: |
|
1311 | a. Your remote nodes have their paths configured correctly, with the ipengine and ipcontroller | |
|
1312 | of the python environment you wish to execute code in having top precedence. | |
|
1313 | b. This functionality is untested on Windows. | |
|
1311 | ||
|
1312 | a. Your remote nodes have their paths configured correctly, with the ipengine and ipcontroller | |
|
1313 | of the python environment you wish to execute code in having top precedence. | |
|
1314 | b. This functionality is untested on Windows. | |
|
1314 | 1315 | |
|
1315 | 1316 | If you need different behavior, consider making you own template. |
|
1316 | 1317 | """ |
@@ -46,6 +46,7 b' from IPython.core.error import UsageError' | |||
|
46 | 46 | from IPython.core.magic import Magics |
|
47 | 47 | from IPython.core import magic_arguments |
|
48 | 48 | from IPython.testing.skipdoctest import skip_doctest |
|
49 | from IPython.utils.text import dedent | |
|
49 | 50 | |
|
50 | 51 | #----------------------------------------------------------------------------- |
|
51 | 52 | # Definitions of magic functions for use with IPython |
@@ -108,13 +109,11 b' def output_args(f):' | |||
|
108 | 109 | |
|
109 | 110 | Choices are: |
|
110 | 111 | |
|
111 | type: group outputs of all engines by type (stdout, stderr, displaypub, etc.). | |
|
112 | ||
|
113 |
|
|
|
114 | ||
|
115 | order: like type, but individual displaypub output from each engine is collated. | |
|
116 | For example, if multiple plots are generated by each engine, the first | |
|
117 | figure of each engine will be displayed, then the second of each, etc. | |
|
112 | **type**: group outputs of all engines by type (stdout, stderr, displaypub, etc.). | |
|
113 | **engine**: display all output for each engine together. | |
|
114 | **order**: like type, but individual displaypub output from each engine is collated. | |
|
115 | For example, if multiple plots are generated by each engine, the first | |
|
116 | figure of each engine will be displayed, then the second of each, etc. | |
|
118 | 117 | """ |
|
119 | 118 | ), |
|
120 | 119 | magic_arguments.argument('-o', '--out', dest='save_name', type=str, |
@@ -435,8 +434,8 b' class ParallelMagics(Magics):' | |||
|
435 | 434 | |
|
436 | 435 | |
|
437 | 436 | __doc__ = __doc__.format( |
|
438 |
AUTOPX_DOC = |
|
|
439 |
PX_DOC = |
|
|
440 |
RESULT_DOC = |
|
|
441 |
CONFIG_DOC = |
|
|
437 | AUTOPX_DOC = dedent(ParallelMagics.autopx.__doc__), | |
|
438 | PX_DOC = dedent(ParallelMagics.px.__doc__), | |
|
439 | RESULT_DOC = dedent(ParallelMagics.result.__doc__), | |
|
440 | CONFIG_DOC = dedent(ParallelMagics.pxconfig.__doc__), | |
|
442 | 441 | ) |
@@ -152,8 +152,10 b' class ParallelFunction(RemoteFunction):' | |||
|
152 | 152 | dist : str [default: 'b'] |
|
153 | 153 | The key for which mapObject to use to distribute sequences |
|
154 | 154 | options are: |
|
155 | * 'b' : use contiguous chunks in order | |
|
156 | * 'r' : use round-robin striping | |
|
155 | ||
|
156 | * 'b' : use contiguous chunks in order | |
|
157 | * 'r' : use round-robin striping | |
|
158 | ||
|
157 | 159 | block : bool [default: None] |
|
158 | 160 | Whether to wait for results or not. The default behavior is |
|
159 | 161 | to use the current `block` attribute of `view` |
@@ -162,7 +164,8 b' class ParallelFunction(RemoteFunction):' | |||
|
162 | 164 | ordered : bool [default: True] |
|
163 | 165 | Whether the result should be kept in order. If False, |
|
164 | 166 | results become available as they arrive, regardless of submission order. |
|
165 | **flags : remaining kwargs are passed to View.temp_flags | |
|
167 | **flags | |
|
168 | remaining kwargs are passed to View.temp_flags | |
|
166 | 169 | """ |
|
167 | 170 | |
|
168 | 171 | chunksize = None |
@@ -221,30 +221,27 b' class View(HasTraits):' | |||
|
221 | 221 | raise NotImplementedError("Implement in subclasses") |
|
222 | 222 | |
|
223 | 223 | def apply(self, f, *args, **kwargs): |
|
224 | """calls f(*args, **kwargs) on remote engines, returning the result. | |
|
224 | """calls ``f(*args, **kwargs)`` on remote engines, returning the result. | |
|
225 | 225 | |
|
226 | 226 | This method sets all apply flags via this View's attributes. |
|
227 | 227 | |
|
228 | if self.block is False: | |
|
229 | returns AsyncResult | |
|
230 | else: | |
|
231 | returns actual result of f(*args, **kwargs) | |
|
228 | Returns :class:`~IPython.parallel.client.asyncresult.AsyncResult` | |
|
229 | instance if ``self.block`` is False, otherwise the return value of | |
|
230 | ``f(*args, **kwargs)``. | |
|
232 | 231 | """ |
|
233 | 232 | return self._really_apply(f, args, kwargs) |
|
234 | 233 | |
|
235 | 234 | def apply_async(self, f, *args, **kwargs): |
|
236 | """calls f(*args, **kwargs) on remote engines in a nonblocking manner. | |
|
235 | """calls ``f(*args, **kwargs)`` on remote engines in a nonblocking manner. | |
|
237 | 236 | |
|
238 | returns AsyncResult | |
|
237 | Returns :class:`~IPython.parallel.client.asyncresult.AsyncResult` instance. | |
|
239 | 238 | """ |
|
240 | 239 | return self._really_apply(f, args, kwargs, block=False) |
|
241 | 240 | |
|
242 | 241 | @spin_after |
|
243 | 242 | def apply_sync(self, f, *args, **kwargs): |
|
244 | """calls f(*args, **kwargs) on remote engines in a blocking manner, | |
|
243 | """calls ``f(*args, **kwargs)`` on remote engines in a blocking manner, | |
|
245 | 244 | returning the result. |
|
246 | ||
|
247 | returns: actual result of f(*args, **kwargs) | |
|
248 | 245 | """ |
|
249 | 246 | return self._really_apply(f, args, kwargs, block=True) |
|
250 | 247 | |
@@ -320,8 +317,7 b' class View(HasTraits):' | |||
|
320 | 317 | def get_result(self, indices_or_msg_ids=None): |
|
321 | 318 | """return one or more results, specified by history index or msg_id. |
|
322 | 319 | |
|
323 | See client.get_result for details. | |
|
324 | ||
|
320 | See :meth:`IPython.parallel.client.client.Client.get_result` for details. | |
|
325 | 321 | """ |
|
326 | 322 | |
|
327 | 323 | if indices_or_msg_ids is None: |
@@ -345,9 +341,9 b' class View(HasTraits):' | |||
|
345 | 341 | raise NotImplementedError |
|
346 | 342 | |
|
347 | 343 | def map_async(self, f, *sequences, **kwargs): |
|
348 | """Parallel version of builtin `map`, using this view's engines. | |
|
344 | """Parallel version of builtin :func:`python:map`, using this view's engines. | |
|
349 | 345 | |
|
350 | This is equivalent to map(...block=False) | |
|
346 | This is equivalent to ``map(...block=False)``. | |
|
351 | 347 | |
|
352 | 348 | See `self.map` for details. |
|
353 | 349 | """ |
@@ -357,9 +353,9 b' class View(HasTraits):' | |||
|
357 | 353 | return self.map(f,*sequences,**kwargs) |
|
358 | 354 | |
|
359 | 355 | def map_sync(self, f, *sequences, **kwargs): |
|
360 | """Parallel version of builtin `map`, using this view's engines. | |
|
356 | """Parallel version of builtin :func:`python:map`, using this view's engines. | |
|
361 | 357 | |
|
362 | This is equivalent to map(...block=True) | |
|
358 | This is equivalent to ``map(...block=True)``. | |
|
363 | 359 | |
|
364 | 360 | See `self.map` for details. |
|
365 | 361 | """ |
@@ -369,7 +365,7 b' class View(HasTraits):' | |||
|
369 | 365 | return self.map(f,*sequences,**kwargs) |
|
370 | 366 | |
|
371 | 367 | def imap(self, f, *sequences, **kwargs): |
|
372 | """Parallel version of `itertools.imap`. | |
|
368 | """Parallel version of :func:`itertools.imap`. | |
|
373 | 369 | |
|
374 | 370 | See `self.map` for details. |
|
375 | 371 | |
@@ -575,7 +571,7 b' class DirectView(View):' | |||
|
575 | 571 | |
|
576 | 572 | @sync_results |
|
577 | 573 | def map(self, f, *sequences, **kwargs): |
|
578 | """view.map(f, *sequences, block=self.block) => list|AsyncMapResult | |
|
574 | """``view.map(f, *sequences, block=self.block)`` => list|AsyncMapResult | |
|
579 | 575 | |
|
580 | 576 | Parallel version of builtin `map`, using this View's `targets`. |
|
581 | 577 | |
@@ -597,14 +593,14 b' class DirectView(View):' | |||
|
597 | 593 | Returns |
|
598 | 594 | ------- |
|
599 | 595 | |
|
600 | if block=False: | |
|
601 | AsyncMapResult | |
|
602 | An object like AsyncResult, but which reassembles the sequence of results | |
|
603 | into a single list. AsyncMapResults can be iterated through before all | |
|
604 | results are complete. | |
|
605 | else: | |
|
606 |
|
|
|
607 |
|
|
|
596 | ||
|
597 | If block=False | |
|
598 | An :class:`~IPython.parallel.client.asyncresult.AsyncMapResult` instance. | |
|
599 | An object like AsyncResult, but which reassembles the sequence of results | |
|
600 | into a single list. AsyncMapResults can be iterated through before all | |
|
601 | results are complete. | |
|
602 | else | |
|
603 | A list, the result of ``map(f,*sequences)`` | |
|
608 | 604 | """ |
|
609 | 605 | |
|
610 | 606 | block = kwargs.pop('block', self.block) |
@@ -1056,7 +1052,7 b' class LoadBalancedView(View):' | |||
|
1056 | 1052 | @sync_results |
|
1057 | 1053 | @save_ids |
|
1058 | 1054 | def map(self, f, *sequences, **kwargs): |
|
1059 | """view.map(f, *sequences, block=self.block, chunksize=1, ordered=True) => list|AsyncMapResult | |
|
1055 | """``view.map(f, *sequences, block=self.block, chunksize=1, ordered=True)`` => list|AsyncMapResult | |
|
1060 | 1056 | |
|
1061 | 1057 | Parallel version of builtin `map`, load-balanced by this View. |
|
1062 | 1058 | |
@@ -1091,14 +1087,13 b' class LoadBalancedView(View):' | |||
|
1091 | 1087 | Returns |
|
1092 | 1088 | ------- |
|
1093 | 1089 | |
|
1094 |
if block=False |
|
|
1095 | AsyncMapResult | |
|
1096 |
|
|
|
1097 |
|
|
|
1098 |
|
|
|
1099 |
|
|
|
1100 |
|
|
|
1101 | ||
|
1090 | if block=False | |
|
1091 | An :class:`~IPython.parallel.client.asyncresult.AsyncMapResult` instance. | |
|
1092 | An object like AsyncResult, but which reassembles the sequence of results | |
|
1093 | into a single list. AsyncMapResults can be iterated through before all | |
|
1094 | results are complete. | |
|
1095 | else | |
|
1096 | A list, the result of ``map(f,*sequences)`` | |
|
1102 | 1097 | """ |
|
1103 | 1098 | |
|
1104 | 1099 | # default |
@@ -105,17 +105,16 b' def require(*objects, **mapping):' | |||
|
105 | 105 | and will be pushed to the engine with their __name__. |
|
106 | 106 | Other objects can be passed by keyword arg. |
|
107 | 107 | |
|
108 | Examples | |
|
109 | -------- | |
|
108 | Examples:: | |
|
110 | 109 | |
|
111 | In [1]: @require('numpy') | |
|
112 | ...: def norm(a): | |
|
113 | ...: return numpy.linalg.norm(a,2) | |
|
110 | In [1]: @require('numpy') | |
|
111 | ...: def norm(a): | |
|
112 | ...: return numpy.linalg.norm(a,2) | |
|
114 | 113 | |
|
115 | In [2]: foo = lambda x: x*x | |
|
116 | In [3]: @require(foo) | |
|
117 | ...: def bar(a): | |
|
118 | ...: return foo(1-a) | |
|
114 | In [2]: foo = lambda x: x*x | |
|
115 | In [3]: @require(foo) | |
|
116 | ...: def bar(a): | |
|
117 | ...: return foo(1-a) | |
|
119 | 118 | """ |
|
120 | 119 | names = [] |
|
121 | 120 | for obj in objects: |
@@ -6,37 +6,42 b' Authors:' | |||
|
6 | 6 | * Min RK |
|
7 | 7 | |
|
8 | 8 | |
|
9 | TaskRecords are dicts of the form: | |
|
10 | { | |
|
11 | 'msg_id' : str(uuid), | |
|
12 |
|
|
|
13 |
|
|
|
14 | 'header' : dict(header), | |
|
15 | 'content': dict(content), | |
|
16 | 'buffers': list(buffers), | |
|
17 | 'submitted': datetime, | |
|
18 |
'st |
|
|
19 |
|
|
|
20 |
|
|
|
21 |
'resu |
|
|
22 |
'result_ |
|
|
23 |
'result_ |
|
|
24 | } | |
|
25 | With this info, many of the special categories of tasks can be defined by query: | |
|
26 | ||
|
27 | pending: completed is None | |
|
28 | client's outstanding: client_uuid = uuid && completed is None | |
|
29 | MIA: arrived is None (and completed is None) | |
|
30 | etc. | |
|
9 | TaskRecords are dicts of the form:: | |
|
10 | ||
|
11 | { | |
|
12 | 'msg_id' : str(uuid), | |
|
13 | 'client_uuid' : str(uuid), | |
|
14 | 'engine_uuid' : str(uuid) or None, | |
|
15 | 'header' : dict(header), | |
|
16 | 'content': dict(content), | |
|
17 | 'buffers': list(buffers), | |
|
18 | 'submitted': datetime, | |
|
19 | 'started': datetime or None, | |
|
20 | 'completed': datetime or None, | |
|
21 | 'resubmitted': datetime or None, | |
|
22 | 'result_header' : dict(header) or None, | |
|
23 | 'result_content' : dict(content) or None, | |
|
24 | 'result_buffers' : list(buffers) or None, | |
|
25 | } | |
|
26 | ||
|
27 | With this info, many of the special categories of tasks can be defined by query, | |
|
28 | e.g.: | |
|
29 | ||
|
30 | * pending: completed is None | |
|
31 | * client's outstanding: client_uuid = uuid && completed is None | |
|
32 | * MIA: arrived is None (and completed is None) | |
|
33 | ||
|
34 | EngineRecords are dicts of the form:: | |
|
35 | ||
|
36 | { | |
|
37 | 'eid' : int(id), | |
|
38 | 'uuid': str(uuid) | |
|
39 | } | |
|
31 | 40 | |
|
32 | EngineRecords are dicts of the form: | |
|
33 | { | |
|
34 | 'eid' : int(id), | |
|
35 | 'uuid': str(uuid) | |
|
36 | } | |
|
37 | 41 | This may be extended, but is currently. |
|
38 | 42 | |
|
39 | We support a subset of mongodb operators: | |
|
43 | We support a subset of mongodb operators:: | |
|
44 | ||
|
40 | 45 | $lt,$gt,$lte,$gte,$ne,$in,$nin,$all,$mod,$exists |
|
41 | 46 | """ |
|
42 | 47 | #----------------------------------------------------------------------------- |
@@ -1149,11 +1149,15 b' class Hub(SessionFactory):' | |||
|
1149 | 1149 | |
|
1150 | 1150 | def queue_status(self, client_id, msg): |
|
1151 | 1151 | """Return the Queue status of one or more targets. |
|
1152 | if verbose: return the msg_ids | |
|
1153 |
else |
|
|
1154 | keys: queue (pending MUX jobs) | |
|
1155 | tasks (pending Task jobs) | |
|
1156 | completed (finished jobs from both queues)""" | |
|
1152 | ||
|
1153 | If verbose, return the msg_ids, else return len of each type. | |
|
1154 | ||
|
1155 | Keys: | |
|
1156 | ||
|
1157 | * queue (pending MUX jobs) | |
|
1158 | * tasks (pending Task jobs) | |
|
1159 | * completed (finished jobs from both queues) | |
|
1160 | """ | |
|
1157 | 1161 | content = msg['content'] |
|
1158 | 1162 | targets = content['targets'] |
|
1159 | 1163 | try: |
@@ -199,7 +199,8 b' def disambiguate_url(url, location=None):' | |||
|
199 | 199 | """turn multi-ip interfaces '0.0.0.0' and '*' into connectable |
|
200 | 200 | ones, based on the location (default interpretation is localhost). |
|
201 | 201 | |
|
202 |
This is for zeromq urls, such as tcp://*:10101. |
|
|
202 | This is for zeromq urls, such as ``tcp://*:10101``. | |
|
203 | """ | |
|
203 | 204 | try: |
|
204 | 205 | proto,ip,port = split_url(url) |
|
205 | 206 | except AssertionError: |
@@ -236,8 +236,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
236 | 236 | def __init__(self, parent=None, **kw): |
|
237 | 237 | """ Create a ConsoleWidget. |
|
238 | 238 | |
|
239 |
Parameters |
|
|
240 |
---------- |
|
|
239 | Parameters | |
|
240 | ---------- | |
|
241 | 241 | parent : QWidget, optional [default None] |
|
242 | 242 | The parent for this widget. |
|
243 | 243 | """ |
@@ -543,8 +543,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
543 | 543 | def clear(self, keep_input=True): |
|
544 | 544 | """ Clear the console. |
|
545 | 545 | |
|
546 |
Parameters |
|
|
547 |
---------- |
|
|
546 | Parameters | |
|
547 | ---------- | |
|
548 | 548 | keep_input : bool, optional (default True) |
|
549 | 549 | If set, restores the old input buffer if a new prompt is written. |
|
550 | 550 | """ |
@@ -580,8 +580,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
580 | 580 | """ Executes source or the input buffer, possibly prompting for more |
|
581 | 581 | input. |
|
582 | 582 | |
|
583 |
Parameters |
|
|
584 |
---------- |
|
|
583 | Parameters | |
|
584 | ---------- | |
|
585 | 585 | source : str, optional |
|
586 | 586 | |
|
587 | 587 | The source to execute. If not specified, the input buffer will be |
@@ -600,14 +600,14 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
600 | 600 | entered by the user. The effect of this parameter depends on the |
|
601 | 601 | subclass implementation. |
|
602 | 602 | |
|
603 |
Raises |
|
|
604 |
------ |
|
|
603 | Raises | |
|
604 | ------ | |
|
605 | 605 | RuntimeError |
|
606 | 606 | If incomplete input is given and 'hidden' is True. In this case, |
|
607 | 607 | it is not possible to prompt for more input. |
|
608 | 608 | |
|
609 |
Returns |
|
|
610 |
------- |
|
|
609 | Returns | |
|
610 | ------- | |
|
611 | 611 | A boolean indicating whether the source was executed. |
|
612 | 612 | """ |
|
613 | 613 | # WARNING: The order in which things happen here is very particular, in |
@@ -746,8 +746,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
746 | 746 | def paste(self, mode=QtGui.QClipboard.Clipboard): |
|
747 | 747 | """ Paste the contents of the clipboard into the input region. |
|
748 | 748 | |
|
749 |
Parameters |
|
|
750 |
---------- |
|
|
749 | Parameters | |
|
750 | ---------- | |
|
751 | 751 | mode : QClipboard::Mode, optional [default QClipboard::Clipboard] |
|
752 | 752 | |
|
753 | 753 | Controls which part of the system clipboard is used. This can be |
@@ -1060,8 +1060,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
1060 | 1060 | """ Given a KeyboardModifiers flags object, return whether the Control |
|
1061 | 1061 | key is down. |
|
1062 | 1062 | |
|
1063 |
Parameters |
|
|
1064 |
---------- |
|
|
1063 | Parameters | |
|
1064 | ---------- | |
|
1065 | 1065 | include_command : bool, optional (default True) |
|
1066 | 1066 | Whether to treat the Command key as a (mutually exclusive) synonym |
|
1067 | 1067 | for Control when in Mac OS. |
@@ -1868,8 +1868,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
1868 | 1868 | """ Displays text using the pager if it exceeds the height of the |
|
1869 | 1869 | viewport. |
|
1870 | 1870 | |
|
1871 |
Parameters |
|
|
1872 |
---------- |
|
|
1871 | Parameters | |
|
1872 | ---------- | |
|
1873 | 1873 | html : bool, optional (default False) |
|
1874 | 1874 | If set, the text will be interpreted as HTML instead of plain text. |
|
1875 | 1875 | """ |
@@ -1903,11 +1903,8 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||
|
1903 | 1903 | """ |
|
1904 | 1904 | Change the pager to `paging` style. |
|
1905 | 1905 | |
|
1906 | XXX: currently, this is limited to switching between 'hsplit' and | |
|
1907 | 'vsplit'. | |
|
1908 | ||
|
1909 | Parameters: | |
|
1910 | ----------- | |
|
1906 | Parameters | |
|
1907 | ---------- | |
|
1911 | 1908 | paging : string |
|
1912 | 1909 | Either "hsplit", "vsplit", or "inside" |
|
1913 | 1910 | """ |
@@ -155,15 +155,15 b' class HistoryConsoleWidget(ConsoleWidget):' | |||
|
155 | 155 | def history_previous(self, substring='', as_prefix=True): |
|
156 | 156 | """ If possible, set the input buffer to a previous history item. |
|
157 | 157 | |
|
158 |
Parameters |
|
|
159 |
---------- |
|
|
158 | Parameters | |
|
159 | ---------- | |
|
160 | 160 | substring : str, optional |
|
161 | 161 | If specified, search for an item with this substring. |
|
162 | 162 | as_prefix : bool, optional |
|
163 | 163 | If True, the substring must match at the beginning (default). |
|
164 | 164 | |
|
165 |
Returns |
|
|
166 |
------- |
|
|
165 | Returns | |
|
166 | ------- | |
|
167 | 167 | Whether the input buffer was changed. |
|
168 | 168 | """ |
|
169 | 169 | index = self._history_index |
@@ -186,15 +186,15 b' class HistoryConsoleWidget(ConsoleWidget):' | |||
|
186 | 186 | def history_next(self, substring='', as_prefix=True): |
|
187 | 187 | """ If possible, set the input buffer to a subsequent history item. |
|
188 | 188 | |
|
189 |
Parameters |
|
|
190 |
---------- |
|
|
189 | Parameters | |
|
190 | ---------- | |
|
191 | 191 | substring : str, optional |
|
192 | 192 | If specified, search for an item with this substring. |
|
193 | 193 | as_prefix : bool, optional |
|
194 | 194 | If True, the substring must match at the beginning (default). |
|
195 | 195 | |
|
196 |
Returns |
|
|
197 |
------- |
|
|
196 | Returns | |
|
197 | ------- | |
|
198 | 198 | Whether the input buffer was changed. |
|
199 | 199 | """ |
|
200 | 200 | index = self._history_index |
@@ -217,8 +217,8 b' class HistoryConsoleWidget(ConsoleWidget):' | |||
|
217 | 217 | def history_tail(self, n=10): |
|
218 | 218 | """ Get the local history list. |
|
219 | 219 | |
|
220 |
Parameters |
|
|
221 |
---------- |
|
|
220 | Parameters | |
|
221 | ---------- | |
|
222 | 222 | n : int |
|
223 | 223 | The (maximum) number of history items to get. |
|
224 | 224 | """ |
@@ -438,8 +438,8 b' class IPythonWidget(FrontendWidget):' | |||
|
438 | 438 | def set_default_style(self, colors='lightbg'): |
|
439 | 439 | """ Sets the widget style to the class defaults. |
|
440 | 440 | |
|
441 |
Parameters |
|
|
442 |
---------- |
|
|
441 | Parameters | |
|
442 | ---------- | |
|
443 | 443 | colors : str, optional (default lightbg) |
|
444 | 444 | Whether to use the default IPython light background or dark |
|
445 | 445 | background or B&W style. |
@@ -464,8 +464,8 b' class IPythonWidget(FrontendWidget):' | |||
|
464 | 464 | def _edit(self, filename, line=None): |
|
465 | 465 | """ Opens a Python script for editing. |
|
466 | 466 | |
|
467 |
Parameters |
|
|
468 |
---------- |
|
|
467 | Parameters | |
|
468 | ---------- | |
|
469 | 469 | filename : str |
|
470 | 470 | A path to a local system file. |
|
471 | 471 |
@@ -32,8 +32,8 b' class KillRing(object):' | |||
|
32 | 32 | def yank(self): |
|
33 | 33 | """ Yank back the most recently killed text. |
|
34 | 34 | |
|
35 |
Returns |
|
|
36 |
------- |
|
|
35 | Returns | |
|
36 | ------- | |
|
37 | 37 | A text string or None. |
|
38 | 38 | """ |
|
39 | 39 | self._index = len(self._ring) |
@@ -42,8 +42,8 b' class KillRing(object):' | |||
|
42 | 42 | def rotate(self): |
|
43 | 43 | """ Rotate the kill ring, then yank back the new top. |
|
44 | 44 | |
|
45 |
Returns |
|
|
46 |
------- |
|
|
45 | Returns | |
|
46 | ------- | |
|
47 | 47 | A text string or None. |
|
48 | 48 | """ |
|
49 | 49 | self._index -= 1 |
@@ -673,8 +673,8 b' class MainWindow(QtGui.QMainWindow):' | |||
|
673 | 673 | def _get_magic_menu(self,menuidentifier, menulabel=None): |
|
674 | 674 | """return a submagic menu by name, and create it if needed |
|
675 | 675 | |
|
676 |
|
|
|
677 |
---------- |
|
|
676 | Parameters | |
|
677 | ---------- | |
|
678 | 678 | |
|
679 | 679 | menulabel : str |
|
680 | 680 | Label for the menu |
@@ -36,6 +36,10 b' import sys' | |||
|
36 | 36 | if os.name == 'nt': |
|
37 | 37 | old_excepthook = sys.excepthook |
|
38 | 38 | |
|
39 | # Exclude this from our autogenerated API docs. | |
|
40 | undoc = lambda func: func | |
|
41 | ||
|
42 | @undoc | |
|
39 | 43 | def gui_excepthook(exctype, value, tb): |
|
40 | 44 | try: |
|
41 | 45 | import ctypes, traceback |
@@ -126,8 +126,8 b' class HtmlExporter(object):' | |||
|
126 | 126 | def export_html(html, filename, image_tag = None, inline = True): |
|
127 | 127 | """ Export the contents of the ConsoleWidget as HTML. |
|
128 | 128 | |
|
129 |
Parameters |
|
|
130 |
---------- |
|
|
129 | Parameters | |
|
130 | ---------- | |
|
131 | 131 | html : unicode, |
|
132 | 132 | A Python unicode string containing the Qt HTML to export. |
|
133 | 133 | |
@@ -162,8 +162,8 b' def export_html(html, filename, image_tag = None, inline = True):' | |||
|
162 | 162 | def export_xhtml(html, filename, image_tag=None): |
|
163 | 163 | """ Export the contents of the ConsoleWidget as XHTML with inline SVGs. |
|
164 | 164 | |
|
165 |
Parameters |
|
|
166 |
---------- |
|
|
165 | Parameters | |
|
166 | ---------- | |
|
167 | 167 | html : unicode, |
|
168 | 168 | A Python unicode string containing the Qt HTML to export. |
|
169 | 169 | |
@@ -216,8 +216,8 b' def default_image_tag(match, path = None, format = "png"):' | |||
|
216 | 216 | def fix_html(html): |
|
217 | 217 | """ Transforms a Qt-generated HTML string into a standards-compliant one. |
|
218 | 218 | |
|
219 |
Parameters |
|
|
220 |
---------- |
|
|
219 | Parameters | |
|
220 | ---------- | |
|
221 | 221 | html : unicode, |
|
222 | 222 | A Python unicode string containing the Qt HTML. |
|
223 | 223 | """ |
@@ -10,16 +10,16 b' from IPython.utils.py3compat import unicode_type' | |||
|
10 | 10 | def save_svg(string, parent=None): |
|
11 | 11 | """ Prompts the user to save an SVG document to disk. |
|
12 | 12 | |
|
13 |
Parameters |
|
|
14 |
---------- |
|
|
13 | Parameters | |
|
14 | ---------- | |
|
15 | 15 | string : basestring |
|
16 | 16 | A Python string containing a SVG document. |
|
17 | 17 | |
|
18 | 18 | parent : QWidget, optional |
|
19 | 19 | The parent to use for the file dialog. |
|
20 | 20 | |
|
21 |
Returns |
|
|
22 |
------- |
|
|
21 | Returns | |
|
22 | ------- | |
|
23 | 23 | The name of the file to which the document was saved, or None if the save |
|
24 | 24 | was cancelled. |
|
25 | 25 | """ |
@@ -43,8 +43,8 b' def save_svg(string, parent=None):' | |||
|
43 | 43 | def svg_to_clipboard(string): |
|
44 | 44 | """ Copy a SVG document to the clipboard. |
|
45 | 45 | |
|
46 |
Parameters |
|
|
47 |
---------- |
|
|
46 | Parameters | |
|
47 | ---------- | |
|
48 | 48 | string : basestring |
|
49 | 49 | A Python string containing a SVG document. |
|
50 | 50 | """ |
@@ -58,8 +58,8 b' def svg_to_clipboard(string):' | |||
|
58 | 58 | def svg_to_image(string, size=None): |
|
59 | 59 | """ Convert a SVG document to a QImage. |
|
60 | 60 | |
|
61 |
Parameters |
|
|
62 |
---------- |
|
|
61 | Parameters | |
|
62 | ---------- | |
|
63 | 63 | string : basestring |
|
64 | 64 | A Python string containing a SVG document. |
|
65 | 65 | |
@@ -67,13 +67,13 b' def svg_to_image(string, size=None):' | |||
|
67 | 67 | The size of the image that is produced. If not specified, the SVG |
|
68 | 68 | document's default size is used. |
|
69 | 69 | |
|
70 |
Raises |
|
|
71 |
------ |
|
|
70 | Raises | |
|
71 | ------ | |
|
72 | 72 | ValueError |
|
73 | 73 | If an invalid SVG string is provided. |
|
74 | 74 | |
|
75 |
Returns |
|
|
76 |
------- |
|
|
75 | Returns | |
|
76 | ------- | |
|
77 | 77 | A QImage of format QImage.Format_ARGB32. |
|
78 | 78 | """ |
|
79 | 79 | if isinstance(string, unicode_type): |
@@ -31,7 +31,6 b' ipython_promptin:' | |||
|
31 | 31 | The default is 'In [%d]:'. This expects that the line numbers are used |
|
32 | 32 | in the prompt. |
|
33 | 33 | ipython_promptout: |
|
34 | ||
|
35 | 34 | The string to represent the IPython prompt in the generated ReST. The |
|
36 | 35 | default is 'Out [%d]:'. This expects that the line numbers are used |
|
37 | 36 | in the prompt. |
@@ -161,30 +161,28 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
161 | 161 | display_banner=None, global_ns=None, compile_flags=None): |
|
162 | 162 | """Embeds IPython into a running python program. |
|
163 | 163 | |
|
164 | Input: | |
|
165 | ||
|
166 | - header: An optional header message can be specified. | |
|
167 | ||
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 | program variables become visible. | |
|
172 | ||
|
173 |
|
|
|
174 | looking for namespaces (when local_ns or module is None). This | |
|
175 | allows an intermediate caller to make sure that this function gets | |
|
176 | the namespace from the intended level in the stack. By default (0) | |
|
177 |
|
|
|
178 | ||
|
179 | - compile_flags: A bit field identifying the __future__ features | |
|
180 | that are enabled, as passed to the builtin `compile` function. If | |
|
181 | given as None, they are automatically taken from the scope where the | |
|
182 | shell was called. | |
|
183 | ||
|
184 | Warning: it's possible to use this in a program which is being run by | |
|
185 | IPython itself (via %run), but some funny things will happen (a few | |
|
186 | globals get overwritten). In the future this will be cleaned up, as | |
|
187 | there is no fundamental reason why it can't work perfectly.""" | |
|
164 | Parameters | |
|
165 | ---------- | |
|
166 | ||
|
167 | local_ns, module | |
|
168 | Working local namespace (a dict) and module (a module or similar | |
|
169 | object). If given as None, they are automatically taken from the scope | |
|
170 | where the shell was called, so that program variables become visible. | |
|
171 | ||
|
172 | stack_depth : int | |
|
173 | How many levels in the stack to go to looking for namespaces (when | |
|
174 | local_ns or module is None). This allows an intermediate caller to | |
|
175 | make sure that this function gets the namespace from the intended | |
|
176 | level in the stack. By default (0) it will get its locals and globals | |
|
177 | from the immediate caller. | |
|
178 | ||
|
179 | compile_flags | |
|
180 | A bit field identifying the __future__ features | |
|
181 | that are enabled, as passed to the builtin :func:`compile` function. | |
|
182 | If given as None, they are automatically taken from the scope where | |
|
183 | the shell was called. | |
|
184 | ||
|
185 | """ | |
|
188 | 186 | |
|
189 | 187 | if (global_ns is not None) and (module is None): |
|
190 | 188 | warnings.warn("global_ns is deprecated, use module instead.", DeprecationWarning) |
@@ -191,8 +191,7 b' class TerminalMagics(Magics):' | |||
|
191 | 191 | This assigns the pasted block to variable 'foo' as string, without |
|
192 | 192 | executing it (preceding >>> and + is still stripped). |
|
193 | 193 | |
|
194 | Options | |
|
195 | ------- | |
|
194 | Options: | |
|
196 | 195 | |
|
197 | 196 | -r: re-executes the block previously entered by cpaste. |
|
198 | 197 | |
@@ -561,12 +560,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
561 | 560 | The returned line does not include the trailing newline. |
|
562 | 561 | When the user enters the EOF key sequence, EOFError is raised. |
|
563 | 562 | |
|
564 | Optional inputs: | |
|
563 | Parameters | |
|
564 | ---------- | |
|
565 | 565 | |
|
566 | - prompt(''): a string to be printed to prompt the user. | |
|
567 | ||
|
568 | - continue_prompt(False): whether this line is the first one or a | |
|
569 | continuation in a sequence of inputs. | |
|
566 | prompt : str, optional | |
|
567 | A string to be printed to prompt the user. | |
|
570 | 568 | """ |
|
571 | 569 | # Code run by the user may have modified the readline completer state. |
|
572 | 570 | # We must ensure that our completer is back in place. |
@@ -175,20 +175,21 b' def skipif(skip_condition, msg=None):' | |||
|
175 | 175 | |
|
176 | 176 | Parameters |
|
177 | 177 | ---------- |
|
178 | skip_condition : bool or callable. | |
|
179 | Flag to determine whether to skip test. If the condition is a | |
|
180 | callable, it is used at runtime to dynamically make the decision. This | |
|
181 | is useful for tests that may require costly imports, to delay the cost | |
|
182 | until the test suite is actually executed. | |
|
178 | ||
|
179 | skip_condition : bool or callable | |
|
180 | Flag to determine whether to skip test. If the condition is a | |
|
181 | callable, it is used at runtime to dynamically make the decision. This | |
|
182 | is useful for tests that may require costly imports, to delay the cost | |
|
183 | until the test suite is actually executed. | |
|
183 | 184 | msg : string |
|
184 |
|
|
|
185 | ||
|
186 | Returns | |
|
187 | ------- | |
|
188 | decorator : function | |
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
185 | Message to give on raising a SkipTest exception. | |
|
186 | ||
|
187 | Returns | |
|
188 | ------- | |
|
189 | decorator : function | |
|
190 | Decorator, which, when applied to a function, causes SkipTest | |
|
191 | to be raised when the skip_condition was True, and the function | |
|
192 | to be called normally otherwise. | |
|
192 | 193 | |
|
193 | 194 | Notes |
|
194 | 195 | ----- |
@@ -59,17 +59,17 b' def full_path(startPath,files):' | |||
|
59 | 59 | """Make full paths for all the listed files, based on startPath. |
|
60 | 60 | |
|
61 | 61 | Only the base part of startPath is kept, since this routine is typically |
|
62 |
used with a script's __file__ variable as startPath. |
|
|
62 | used with a script's ``__file__`` variable as startPath. The base of startPath | |
|
63 | 63 | is then prepended to all the listed files, forming the output list. |
|
64 | 64 | |
|
65 | 65 | Parameters |
|
66 | 66 | ---------- |
|
67 |
|
|
|
68 |
|
|
|
67 | startPath : string | |
|
68 | Initial path to use as the base for the results. This path is split | |
|
69 | 69 | using os.path.split() and only its first component is kept. |
|
70 | 70 | |
|
71 |
|
|
|
72 |
|
|
|
71 | files : string or list | |
|
72 | One or more files. | |
|
73 | 73 | |
|
74 | 74 | Examples |
|
75 | 75 | -------- |
@@ -80,9 +80,10 b' def full_path(startPath,files):' | |||
|
80 | 80 | >>> full_path('/foo',['a.txt','b.txt']) |
|
81 | 81 | ['/a.txt', '/b.txt'] |
|
82 | 82 | |
|
83 | If a single file is given, the output is still a list: | |
|
84 | >>> full_path('/foo','a.txt') | |
|
85 | ['/a.txt'] | |
|
83 | If a single file is given, the output is still a list:: | |
|
84 | ||
|
85 | >>> full_path('/foo','a.txt') | |
|
86 | ['/a.txt'] | |
|
86 | 87 | """ |
|
87 | 88 | |
|
88 | 89 | files = list_strings(files) |
@@ -105,7 +106,8 b' def parse_test_output(txt):' | |||
|
105 | 106 | |
|
106 | 107 | Returns |
|
107 | 108 | ------- |
|
108 | nerr, nfail: number of errors and failures. | |
|
109 | nerr, nfail | |
|
110 | number of errors and failures. | |
|
109 | 111 | """ |
|
110 | 112 | |
|
111 | 113 | err_m = re.search(r'^FAILED \(errors=(\d+)\)', txt, re.MULTILINE) |
@@ -81,11 +81,12 b' def belong(candidates,checklist):' | |||
|
81 | 81 | def with_obj(object, **args): |
|
82 | 82 | """Set multiple attributes for an object, similar to Pascal's with. |
|
83 | 83 | |
|
84 | Example: | |
|
85 | with_obj(jim, | |
|
86 | born = 1960, | |
|
87 | haircolour = 'Brown', | |
|
88 |
|
|
|
84 | Example:: | |
|
85 | ||
|
86 | with_obj(jim, | |
|
87 | born = 1960, | |
|
88 | haircolour = 'Brown', | |
|
89 | eyecolour = 'Green') | |
|
89 | 90 | |
|
90 | 91 | Credit: Greg Ewing, in |
|
91 | 92 | http://mail.python.org/pipermail/python-list/2001-May/040703.html. |
@@ -48,8 +48,9 b' color_templates = (' | |||
|
48 | 48 | def make_color_table(in_class): |
|
49 | 49 | """Build a set of color attributes in a class. |
|
50 | 50 | |
|
51 |
Helper function for building the |
|
|
52 | ||
|
51 | Helper function for building the :class:`TermColors` and | |
|
52 | :class`InputTermColors`. | |
|
53 | """ | |
|
53 | 54 | for name,value in color_templates: |
|
54 | 55 | setattr(in_class,name,in_class._base % value) |
|
55 | 56 |
@@ -26,17 +26,20 b' from IPython.utils import py3compat' | |||
|
26 | 26 | def extract_vars(*names,**kw): |
|
27 | 27 | """Extract a set of variables by name from another frame. |
|
28 | 28 | |
|
29 |
|
|
|
30 | - `*names`: strings | |
|
29 | Parameters | |
|
30 | ---------- | |
|
31 | *names : str | |
|
31 | 32 | One or more variable names which will be extracted from the caller's |
|
32 | frame. | |
|
33 | frame. | |
|
33 | 34 | |
|
34 | :Keywords: | |
|
35 | - `depth`: integer (0) | |
|
35 | depth : integer, optional | |
|
36 | 36 | How many frames in the stack to walk when looking for your variables. |
|
37 | The default is 0, which will use the frame where the call was made. | |
|
37 | 38 | |
|
38 | 39 | |
|
39 |
Examples |
|
|
40 | Examples | |
|
41 | -------- | |
|
42 | :: | |
|
40 | 43 | |
|
41 | 44 | In [2]: def func(x): |
|
42 | 45 | ...: y = 1 |
@@ -110,10 +110,10 b' class SList(list):' | |||
|
110 | 110 | |
|
111 | 111 | These are normal lists, but with the special attributes: |
|
112 | 112 | |
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
113 | * .l (or .list) : value as list (the list itself). | |
|
114 | * .n (or .nlstr): value as a string, joined on newlines. | |
|
115 | * .s (or .spstr): value as a string, joined on spaces. | |
|
116 | * .p (or .paths): list of path objects | |
|
117 | 117 | |
|
118 | 118 | Any values which require transformations are computed only once and |
|
119 | 119 | cached.""" |
@@ -191,13 +191,14 b' class SList(list):' | |||
|
191 | 191 | Allows quick awk-like usage of string lists. |
|
192 | 192 | |
|
193 | 193 | Example data (in var a, created by 'a = !ls -l'):: |
|
194 | ||
|
194 | 195 | -rwxrwxrwx 1 ville None 18 Dec 14 2006 ChangeLog |
|
195 | 196 | drwxrwxrwx+ 6 ville None 0 Oct 24 18:05 IPython |
|
196 | 197 | |
|
197 | a.fields(0) is ['-rwxrwxrwx', 'drwxrwxrwx+'] | |
|
198 | a.fields(1,0) is ['1 -rwxrwxrwx', '6 drwxrwxrwx+'] | |
|
199 | (note the joining by space). | |
|
200 | a.fields(-1) is ['ChangeLog', 'IPython'] | |
|
198 | * ``a.fields(0)`` is ``['-rwxrwxrwx', 'drwxrwxrwx+']`` | |
|
199 | * ``a.fields(1,0)`` is ``['1 -rwxrwxrwx', '6 drwxrwxrwx+']`` | |
|
200 | (note the joining by space). | |
|
201 | * ``a.fields(-1)`` is ``['ChangeLog', 'IPython']`` | |
|
201 | 202 | |
|
202 | 203 | IndexErrors are ignored. |
|
203 | 204 |
@@ -761,8 +761,8 b' class Instance(ClassBasedTraitType):' | |||
|
761 | 761 | allow_none : bool |
|
762 | 762 | Indicates whether None is allowed as a value. |
|
763 | 763 | |
|
764 | Default Value | |
|
765 |
----- |
|
|
764 | Notes | |
|
765 | ----- | |
|
766 | 766 | If both ``args`` and ``kw`` are None, then the default value is None. |
|
767 | 767 | If ``args`` is a tuple and ``kw`` is a dict, then the default is |
|
768 | 768 | created as ``klass(*args, **kw)``. If either ``args`` or ``kw`` is |
@@ -17,45 +17,29 b" if __name__ == '__main__':" | |||
|
17 | 17 | docwriter = ApiDocWriter(package,rst_extension='.rst') |
|
18 | 18 | # You have to escape the . here because . is a special char for regexps. |
|
19 | 19 | # You must do make clean if you change this! |
|
20 |
docwriter.package_skip_patterns += [r'\. |
|
|
21 |
|
|
|
20 | docwriter.package_skip_patterns += [r'\.external$', | |
|
21 | # Extensions are documented elsewhere. | |
|
22 | 22 | r'\.extensions', |
|
23 | r'\.kernel\.config', | |
|
24 | r'\.attic', | |
|
25 | r'\.quarantine', | |
|
26 | r'\.deathrow', | |
|
27 | r'\.config\.default', | |
|
28 | 23 | r'\.config\.profile', |
|
29 | r'\.frontend', | |
|
30 | r'\.gui', | |
|
31 | r'\.kernel', | |
|
32 | # For now, the zmq code has | |
|
33 | # unconditional top-level code so it's | |
|
34 | # not import safe. This needs fixing | |
|
35 | r'\.zmq', | |
|
36 | 24 | ] |
|
37 | 25 | |
|
38 | docwriter.module_skip_patterns += [ | |
|
39 | r'\.testing\.iptest', | |
|
40 | # Keeping these disabled is OK | |
|
41 | r'\.parallel\.controller\.mongodb', | |
|
42 | r'\.lib\.inputhookwx', | |
|
43 | r'\.lib\.inputhookgtk', | |
|
44 | r'\.cocoa', | |
|
26 | # The inputhook* modules often cause problems on import, such as trying to | |
|
27 | # load incompatible Qt bindings. It's easiest to leave them all out. The | |
|
28 | # main API is in the inputhook module, which is documented. | |
|
29 | docwriter.module_skip_patterns += [ r'\.lib\.inputhook.+', | |
|
45 | 30 | r'\.ipdoctest', |
|
46 |
r'\. |
|
|
47 | r'\.frontend\.process\.winprocess', | |
|
31 | r'\.testing\.plugin', | |
|
32 | # This just prints a deprecation msg: | |
|
48 | 33 | r'\.frontend', |
|
49 | r'\.Shell', | |
|
50 | 34 | ] |
|
51 | 35 | |
|
52 | # If we don't have pexpect, we can't load irunner, so skip any code that | |
|
53 | # depends on it | |
|
36 | # We're rarely working on machines with the Azure SDK installed, so we | |
|
37 | # skip the module that needs it in that case. | |
|
54 | 38 | try: |
|
55 | import pexpect | |
|
39 | import azure # analysis:ignore | |
|
56 | 40 | except ImportError: |
|
57 |
docwriter.module_skip_patterns |
|
|
58 | r'\.testing\.mkdoctests'] | |
|
41 | docwriter.module_skip_patterns.append(r'\.html\.services\.notebooks\.azurenbmanager') | |
|
42 | ||
|
59 | 43 | # Now, generate the outputs |
|
60 | 44 | docwriter.write_api_docs(outdir) |
|
61 | 45 | # Write index with .txt extension - we can include it, but Sphinx won't try |
@@ -44,6 +44,7 b' extensions = [' | |||
|
44 | 44 | 'matplotlib.sphinxext.only_directives', |
|
45 | 45 | 'matplotlib.sphinxext.plot_directive', |
|
46 | 46 | 'sphinx.ext.autodoc', |
|
47 | 'sphinx.ext.autosummary', | |
|
47 | 48 | 'sphinx.ext.doctest', |
|
48 | 49 | 'sphinx.ext.inheritance_diagram', |
|
49 | 50 | 'sphinx.ext.intersphinx', |
@@ -179,7 +180,7 b' html_additional_pages = {' | |||
|
179 | 180 | # Output file base name for HTML help builder. |
|
180 | 181 | htmlhelp_basename = 'ipythondoc' |
|
181 | 182 | |
|
182 |
intersphinx_mapping = {' |
|
|
183 | intersphinx_mapping = {'python': ('http://docs.python.org/2/', None)} | |
|
183 | 184 | |
|
184 | 185 | # Options for LaTeX output |
|
185 | 186 | # ------------------------ |
@@ -116,8 +116,7 b' The generated comparison, is between your feature branch' | |||
|
116 | 116 | ``my-new-feature``, and the place in ``master`` from which you branched |
|
117 | 117 | ``my-new-feature``. In other words, you can keep updating ``master`` |
|
118 | 118 | without interfering with the output from the comparison. More detail? |
|
119 |
Note the three dots in the URL above (``master...my-new-feature``) |
|
|
120 | see :ref:`dot2-dot3`. | |
|
119 | Note the three dots in the URL above (``master...my-new-feature``). | |
|
121 | 120 | |
|
122 | 121 | Asking for your changes to be merged with the main repo |
|
123 | 122 | ======================================================= |
@@ -26,3 +26,4 b' on the IPython GitHub wiki.' | |||
|
26 | 26 | parallel_connections |
|
27 | 27 | pycompat |
|
28 | 28 | config |
|
29 | inputhook_app |
@@ -140,7 +140,7 b' Pull requests (257):' | |||
|
140 | 140 | * `1126 <https://github.com/ipython/ipython/issues/1126>`_: Totally remove pager when read only (notebook) |
|
141 | 141 | * `1091 <https://github.com/ipython/ipython/issues/1091>`_: qtconsole : allow copy with shortcut in pager |
|
142 | 142 | * `1114 <https://github.com/ipython/ipython/issues/1114>`_: fix magics history in two-process ipython console |
|
143 |
* `1113 <https://github.com/ipython/ipython/issues/1113>`_: Fixing #1112 removing failing asserts for test_carriage_return and test_ |
|
|
143 | * `1113 <https://github.com/ipython/ipython/issues/1113>`_: Fixing #1112 removing failing asserts for test_carriage_return and test_beep | |
|
144 | 144 | * `1089 <https://github.com/ipython/ipython/issues/1089>`_: Support carriage return ('\r') and beep ('\b') characters in the qtconsole |
|
145 | 145 | * `1108 <https://github.com/ipython/ipython/issues/1108>`_: Completer usability 2 (rebased of pr #1082) |
|
146 | 146 | * `864 <https://github.com/ipython/ipython/issues/864>`_: Two-process terminal frontend (ipython core branch) |
@@ -643,7 +643,7 b' Pull Requests (793):' | |||
|
643 | 643 | * :ghpull:`3223`: add missing mathjax_url to new settings dict |
|
644 | 644 | * :ghpull:`3089`: add stdin to the notebook |
|
645 | 645 | * :ghpull:`3221`: Remove references to HTMLCell (dead code) |
|
646 | * :ghpull:`3205`: add ignored *args to HasTraits constructor | |
|
646 | * :ghpull:`3205`: add ignored ``*args`` to HasTraits constructor | |
|
647 | 647 | * :ghpull:`3088`: cleanup IPython handler settings |
|
648 | 648 | * :ghpull:`3201`: use much faster regexp for ansi coloring |
|
649 | 649 | * :ghpull:`3220`: avoid race condition in profile creation |
@@ -1064,7 +1064,7 b' Pull Requests (793):' | |||
|
1064 | 1064 | * :ghpull:`2140`: 2to3: Apply `has_key` fixer. |
|
1065 | 1065 | * :ghpull:`2131`: Add option append (-a) to %save |
|
1066 | 1066 | * :ghpull:`2117`: use explicit url in notebook example |
|
1067 | * :ghpull:`2133`: Tell git that *.py files contain Python code, for use in word-diffs. | |
|
1067 | * :ghpull:`2133`: Tell git that ``*.py`` files contain Python code, for use in word-diffs. | |
|
1068 | 1068 | * :ghpull:`2134`: Apply 2to3 `next` fix. |
|
1069 | 1069 | * :ghpull:`2126`: ipcluster broken with any batch launcher (PBS/LSF/SGE) |
|
1070 | 1070 | * :ghpull:`2104`: Windows make file for Sphinx documentation |
@@ -1423,7 +1423,7 b' Issues (691):' | |||
|
1423 | 1423 | * :ghissue:`3207`: [Feature] folders for ipython notebook dashboard |
|
1424 | 1424 | * :ghissue:`3178`: cell magics do not work with empty lines after #2447 |
|
1425 | 1425 | * :ghissue:`3204`: Default plot() colors unsuitable for red-green colorblind users |
|
1426 | * :ghissue:`1789`: :\n/*foo turns into :\n*(foo) in triple-quoted strings. | |
|
1426 | * :ghissue:`1789`: ``:\n/*foo`` turns into ``:\n*(foo)`` in triple-quoted strings. | |
|
1427 | 1427 | * :ghissue:`3202`: File cell magic fails with blank lines |
|
1428 | 1428 | * :ghissue:`3199`: %%cython -a stopped working? |
|
1429 | 1429 | * :ghissue:`2688`: obsolete imports in import autocompletion |
@@ -1649,7 +1649,7 b' Issues (691):' | |||
|
1649 | 1649 | * :ghissue:`1308`: ipython qtconsole --ssh=server --existing ... hangs |
|
1650 | 1650 | * :ghissue:`1679`: List command doesn't work in ipdb debugger the first time |
|
1651 | 1651 | * :ghissue:`2545`: pypi win32 installer creates 64bit executibles |
|
1652 | * :ghissue:`2080`: Event loop issues with IPython 0.12 and PyQt4 (QDialog.exec_ and more) | |
|
1652 | * :ghissue:`2080`: Event loop issues with IPython 0.12 and PyQt4 (``QDialog.exec_`` and more) | |
|
1653 | 1653 | * :ghissue:`2541`: Allow `python -m IPython` |
|
1654 | 1654 | * :ghissue:`2508`: subplots_adjust() does not work correctly in ipython notebook |
|
1655 | 1655 | * :ghissue:`2289`: Incorrect mathjax rendering of certain arrays of equations |
@@ -547,7 +547,7 b' Backwards incompatible changes' | |||
|
547 | 547 | |
|
548 | 548 | * Old style configuration files :file:`ipythonrc` and :file:`ipy_user_conf.py` |
|
549 | 549 | are no longer supported. Users should migrate there configuration files to |
|
550 | the new format described :doc:`here <config/intro>` and | |
|
550 | the new format described :doc:`here </config/intro>` and | |
|
551 | 551 | :ref:`here <config_overview>`. |
|
552 | 552 | |
|
553 | 553 | * The old IPython extension API that relied on :func:`ipapi` has been |
@@ -220,7 +220,7 b' class ApiDocWriter(object):' | |||
|
220 | 220 | # get the names of all classes and functions |
|
221 | 221 | functions, classes = self._parse_module(uri) |
|
222 | 222 | if not len(functions) and not len(classes): |
|
223 | print ('WARNING: Empty -', uri) # dbg | |
|
223 | #print ('WARNING: Empty -', uri) # dbg | |
|
224 | 224 | return '' |
|
225 | 225 | |
|
226 | 226 | # Make a shorter version of the uri that omits the package name for |
@@ -415,7 +415,8 b' class ApiDocWriter(object):' | |||
|
415 | 415 | idx = open(path,'wt') |
|
416 | 416 | w = idx.write |
|
417 | 417 | w('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n') |
|
418 |
w('.. |
|
|
419 | for f in self.written_modules: | |
|
420 | w(' %s\n' % os.path.join(relpath,f)) | |
|
418 | w('.. autosummary::\n' | |
|
419 | ' :toctree: %s\n\n' % relpath) | |
|
420 | for mod in self.written_modules: | |
|
421 | w(' %s\n' % mod) | |
|
421 | 422 | idx.close() |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now