Show More
@@ -1,58 +1,24 b'' | |||||
1 | """Analysis of text input into executable blocks. |
|
1 | """Input handling and transformation machinery. | |
2 |
|
2 | |||
3 |
The |
|
3 | The first class in this module, :class:`InputSplitter`, is designed to tell when | |
4 | input from either interactive, line-by-line environments or block-based ones, |
|
4 | input from a line-oriented frontend is complete and should be executed, and when | |
5 | into standalone blocks that can be executed by Python as 'single' statements |
|
5 | the user should be prompted for another line of code instead. The name 'input | |
6 | (thus triggering sys.displayhook). |
|
6 | splitter' is largely for historical reasons. | |
7 |
|
7 | |||
8 | A companion, :class:`IPythonInputSplitter`, provides the same functionality but |
|
8 | A companion, :class:`IPythonInputSplitter`, provides the same functionality but | |
9 | with full support for the extended IPython syntax (magics, system calls, etc). |
|
9 | with full support for the extended IPython syntax (magics, system calls, etc). | |
|
10 | The code to actually do these transformations is in :mod:`IPython.core.inputtransformer`. | |||
|
11 | :class:`IPythonInputSplitter` feeds the raw code to the transformers in order | |||
|
12 | and stores the results. | |||
10 |
|
13 | |||
11 | For more details, see the class docstring below. |
|
14 | For more details, see the class docstrings below. | |
12 |
|
||||
13 | Syntax Transformations |
|
|||
14 | ---------------------- |
|
|||
15 |
|
||||
16 | One of the main jobs of the code in this file is to apply all syntax |
|
|||
17 | transformations that make up 'the IPython language', i.e. magics, shell |
|
|||
18 | escapes, etc. All transformations should be implemented as *fully stateless* |
|
|||
19 | entities, that simply take one line as their input and return a line. |
|
|||
20 | Internally for implementation purposes they may be a normal function or a |
|
|||
21 | callable object, but the only input they receive will be a single line and they |
|
|||
22 | should only return a line, without holding any data-dependent state between |
|
|||
23 | calls. |
|
|||
24 |
|
||||
25 | As an example, the EscapedTransformer is a class so we can more clearly group |
|
|||
26 | together the functionality of dispatching to individual functions based on the |
|
|||
27 | starting escape character, but the only method for public use is its call |
|
|||
28 | method. |
|
|||
29 |
|
||||
30 |
|
||||
31 | ToDo |
|
|||
32 | ---- |
|
|||
33 |
|
||||
34 | - Should we make push() actually raise an exception once push_accepts_more() |
|
|||
35 | returns False? |
|
|||
36 |
|
||||
37 | - Naming cleanups. The tr_* names aren't the most elegant, though now they are |
|
|||
38 | at least just attributes of a class so not really very exposed. |
|
|||
39 |
|
||||
40 | - Think about the best way to support dynamic things: automagic, autocall, |
|
|||
41 | macros, etc. |
|
|||
42 |
|
||||
43 | - Think of a better heuristic for the application of the transforms in |
|
|||
44 | IPythonInputSplitter.push() than looking at the buffer ending in ':'. Idea: |
|
|||
45 | track indentation change events (indent, dedent, nothing) and apply them only |
|
|||
46 | if the indentation went up, but not otherwise. |
|
|||
47 |
|
||||
48 | - Think of the cleanest way for supporting user-specified transformations (the |
|
|||
49 | user prefilters we had before). |
|
|||
50 |
|
15 | |||
51 | Authors |
|
16 | Authors | |
52 | ------- |
|
17 | ------- | |
53 |
|
18 | |||
54 | * Fernando Perez |
|
19 | * Fernando Perez | |
55 | * Brian Granger |
|
20 | * Brian Granger | |
|
21 | * Thomas Kluyver | |||
56 | """ |
|
22 | """ | |
57 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
58 | # Copyright (C) 2010 The IPython Development Team |
|
24 | # Copyright (C) 2010 The IPython Development Team | |
@@ -598,9 +564,9 b' class IPythonInputSplitter(InputSplitter):' | |||||
598 | ------- |
|
564 | ------- | |
599 | is_complete : boolean |
|
565 | is_complete : boolean | |
600 | True if the current input source (the result of the current input |
|
566 | True if the current input source (the result of the current input | |
601 | plus prior inputs) forms a complete Python execution block. Note that |
|
567 | plus prior inputs) forms a complete Python execution block. Note that | |
602 | this value is also stored as a private attribute (_is_complete), so it |
|
568 | this value is also stored as a private attribute (_is_complete), so it | |
603 | can be queried at any time. |
|
569 | can be queried at any time. | |
604 | """ |
|
570 | """ | |
605 |
|
571 | |||
606 | # We must ensure all input is pure unicode |
|
572 | # We must ensure all input is pure unicode |
@@ -1,3 +1,8 b'' | |||||
|
1 | """Input transformer classes to support IPython special syntax. | |||
|
2 | ||||
|
3 | This includes the machinery to recognise and transform ``%magic`` commands, | |||
|
4 | ``!system`` commands, ``help?`` querying, prompt stripping, and so forth. | |||
|
5 | """ | |||
1 | import abc |
|
6 | import abc | |
2 | import functools |
|
7 | import functools | |
3 | import re |
|
8 | import re |
@@ -1,6 +1,6 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | ultratb.py -- Spice up your tracebacks! |
|
3 | Verbose and colourful traceback formatting. | |
4 |
|
4 | |||
5 | **ColorTB** |
|
5 | **ColorTB** | |
6 |
|
6 |
@@ -1,4 +1,4 b'' | |||||
1 | """Publishing |
|
1 | """Publishing native (typically pickled) objects. | |
2 | """ |
|
2 | """ | |
3 |
|
3 | |||
4 | #----------------------------------------------------------------------------- |
|
4 | #----------------------------------------------------------------------------- |
@@ -1,3 +1,5 b'' | |||||
|
1 | """Replacements for sys.displayhook that publish over ZMQ. | |||
|
2 | """ | |||
1 | import sys |
|
3 | import sys | |
2 |
|
4 | |||
3 | from IPython.core.displayhook import DisplayHook |
|
5 | from IPython.core.displayhook import DisplayHook |
@@ -1,4 +1,4 b'' | |||||
1 |
""" |
|
1 | """Some generic utilities for dealing with classes, urls, and serialization. | |
2 |
|
2 | |||
3 | Authors: |
|
3 | Authors: | |
4 |
|
4 |
@@ -1,4 +1,4 b'' | |||||
1 |
""" |
|
1 | """A navigable completer for the qtconsole""" | |
2 | # coding : utf-8 |
|
2 | # coding : utf-8 | |
3 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
4 | # Copyright (c) 2012, IPython Development Team.$ |
|
4 | # Copyright (c) 2012, IPython Development Team.$ |
@@ -1,4 +1,4 b'' | |||||
1 |
""" |
|
1 | """A simple completer for the qtconsole""" | |
2 | #----------------------------------------------------------------------------- |
|
2 | #----------------------------------------------------------------------------- | |
3 | # Copyright (c) 2012, IPython Development Team.$ |
|
3 | # Copyright (c) 2012, IPython Development Team.$ | |
4 | # |
|
4 | # |
@@ -1,3 +1,4 b'' | |||||
|
1 | """A dropdown completer widget for the qtconsole.""" | |||
1 | # System library imports |
|
2 | # System library imports | |
2 | from IPython.external.qt import QtCore, QtGui |
|
3 | from IPython.external.qt import QtCore, QtGui | |
3 |
|
4 |
@@ -1,5 +1,6 b'' | |||||
1 |
""" |
|
1 | """A FrontendWidget that emulates the interface of the console IPython. | |
2 | supports the additional functionality provided by the IPython kernel. |
|
2 | ||
|
3 | This supports the additional functionality provided by the IPython kernel. | |||
3 | """ |
|
4 | """ | |
4 |
|
5 | |||
5 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- |
@@ -1,3 +1,5 b'' | |||||
|
1 | """Adapt readline completer interface to make ZMQ request. | |||
|
2 | """ | |||
1 | # -*- coding: utf-8 -*- |
|
3 | # -*- coding: utf-8 -*- | |
2 | import readline |
|
4 | import readline | |
3 | try: |
|
5 | try: |
@@ -310,7 +310,8 b' def list_strings(arg):' | |||||
310 | """Always return a list of strings, given a string or list of strings |
|
310 | """Always return a list of strings, given a string or list of strings | |
311 | as input. |
|
311 | as input. | |
312 |
|
312 | |||
313 |
|
|
313 | Examples | |
|
314 | -------- | |||
314 | :: |
|
315 | :: | |
315 |
|
316 | |||
316 | In [7]: list_strings('A single string') |
|
317 | In [7]: list_strings('A single string') | |
@@ -330,7 +331,8 b' def list_strings(arg):' | |||||
330 | def marquee(txt='',width=78,mark='*'): |
|
331 | def marquee(txt='',width=78,mark='*'): | |
331 | """Return the input string centered in a 'marquee'. |
|
332 | """Return the input string centered in a 'marquee'. | |
332 |
|
333 | |||
333 |
|
|
334 | Examples | |
|
335 | -------- | |||
334 | :: |
|
336 | :: | |
335 |
|
337 | |||
336 | In [16]: marquee('A test',40) |
|
338 | In [16]: marquee('A test',40) |
@@ -1,4 +1,4 b'' | |||||
1 |
""" |
|
1 | """Utilities for checking zmq versions.""" | |
2 | #----------------------------------------------------------------------------- |
|
2 | #----------------------------------------------------------------------------- | |
3 | # Copyright (C) 2013 The IPython Development Team |
|
3 | # Copyright (C) 2013 The IPython Development Team | |
4 | # |
|
4 | # |
@@ -30,7 +30,7 b" if __name__ == '__main__':" | |||||
30 | r'\.ipdoctest', |
|
30 | r'\.ipdoctest', | |
31 | r'\.testing\.plugin', |
|
31 | r'\.testing\.plugin', | |
32 | # This just prints a deprecation msg: |
|
32 | # This just prints a deprecation msg: | |
33 | r'\.frontend', |
|
33 | r'\.frontend$', | |
34 | ] |
|
34 | ] | |
35 |
|
35 | |||
36 | # We're rarely working on machines with the Azure SDK installed, so we |
|
36 | # We're rarely working on machines with the Azure SDK installed, so we |
@@ -41,7 +41,10 b' attributes :attr:`~IPython.core.interactiveshell.InteractiveShell.input_splitter' | |||||
41 | to tell when a block of input is complete, and |
|
41 | to tell when a block of input is complete, and | |
42 | :attr:`~IPython.core.interactiveshell.InteractiveShell.input_transformer_manager`, |
|
42 | :attr:`~IPython.core.interactiveshell.InteractiveShell.input_transformer_manager`, | |
43 | to transform complete cells. If you add a transformer, you should make sure that |
|
43 | to transform complete cells. If you add a transformer, you should make sure that | |
44 | it gets added to both. |
|
44 | it gets added to both, e.g.:: | |
|
45 | ||||
|
46 | ip.input_splitter.logical_line_transforms.append(my_transformer()) | |||
|
47 | ip.input_transformer_manager.logical_line_transforms.append(my_transformer()) | |||
45 |
|
|
48 | ||
46 | Stateless transformations |
|
49 | Stateless transformations | |
47 | ------------------------- |
|
50 | ------------------------- |
@@ -97,7 +97,7 b' When both Python and JSON configuration file are present, both will be loaded,' | |||||
97 | with JSON configuration having higher priority. |
|
97 | with JSON configuration having higher priority. | |
98 |
|
98 | |||
99 | Python configuration Files |
|
99 | Python configuration Files | |
100 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
100 | -------------------------- | |
101 |
|
101 | |||
102 | A Python configuration file is a pure Python file that populates a configuration object. |
|
102 | A Python configuration file is a pure Python file that populates a configuration object. | |
103 | This configuration object is a :class:`~IPython.config.loader.Config` instance. |
|
103 | This configuration object is a :class:`~IPython.config.loader.Config` instance. | |
@@ -187,7 +187,7 b' attribute of ``c`` is not the actual class, but instead is another' | |||||
187 | hierarchical information created easily (``c.Foo.Bar.value``) on the fly. |
|
187 | hierarchical information created easily (``c.Foo.Bar.value``) on the fly. | |
188 |
|
188 | |||
189 | JSON configuration Files |
|
189 | JSON configuration Files | |
190 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
|
190 | ------------------------ | |
191 |
|
191 | |||
192 | A JSON configuration file is simply a file that contains a |
|
192 | A JSON configuration file is simply a file that contains a | |
193 | :class:`~IPython.config.loader.Config` dictionary serialized to JSON. |
|
193 | :class:`~IPython.config.loader.Config` dictionary serialized to JSON. |
@@ -198,7 +198,8 b' read on for more details.' | |||||
198 | readline |
|
198 | readline | |
199 | -------- |
|
199 | -------- | |
200 |
|
200 | |||
201 | As indicated above, on Windows, PyReadline is a *mandatory* dependency. |
|
201 | As indicated above, on Windows, to get full functionality in the console | |
|
202 | version of IPython, PyReadline is needed. | |||
202 | PyReadline is a separate, Windows only implementation of readline that uses |
|
203 | PyReadline is a separate, Windows only implementation of readline that uses | |
203 | native Windows calls through :mod:`ctypes`. The easiest way of installing |
|
204 | native Windows calls through :mod:`ctypes`. The easiest way of installing | |
204 | PyReadline is you use the binary installer available `here |
|
205 | PyReadline is you use the binary installer available `here |
General Comments 0
You need to be logged in to leave comments.
Login now