Show More
@@ -9,6 +9,7 import abc | |||
|
9 | 9 | import functools |
|
10 | 10 | import re |
|
11 | 11 | import tokenize |
|
12 | import warnings | |
|
12 | 13 | from tokenize import untokenize, TokenError |
|
13 | 14 | from io import StringIO |
|
14 | 15 | |
@@ -43,6 +44,15 ESC_SEQUENCES = [ESC_SHELL, ESC_SH_CAP, ESC_HELP ,\ | |||
|
43 | 44 | class InputTransformer(metaclass=abc.ABCMeta): |
|
44 | 45 | """Abstract base class for line-based input transformers.""" |
|
45 | 46 | |
|
47 | def __init__(self): | |
|
48 | warnings.warn( | |
|
49 | "`InputTransformer` has been deprecated since IPython 7.0" | |
|
50 | " and emit a warnig since IPython 8.31, it" | |
|
51 | " will be removed in the future", | |
|
52 | DeprecationWarning, | |
|
53 | stacklevel=2, | |
|
54 | ) | |
|
55 | ||
|
46 | 56 | @abc.abstractmethod |
|
47 | 57 | def push(self, line): |
|
48 | 58 | """Send a line of input to the transformer, returning the transformed |
@@ -78,6 +88,14 class InputTransformer(metaclass=abc.ABCMeta): | |||
|
78 | 88 | class StatelessInputTransformer(InputTransformer): |
|
79 | 89 | """Wrapper for a stateless input transformer implemented as a function.""" |
|
80 | 90 | def __init__(self, func): |
|
91 | super().__init__() | |
|
92 | warnings.warn( | |
|
93 | "`StatelessInputTransformer` has been deprecated since IPython 7.0" | |
|
94 | " and emit a warnig since IPython 8.31, it" | |
|
95 | " will be removed in the future", | |
|
96 | DeprecationWarning, | |
|
97 | stacklevel=2, | |
|
98 | ) | |
|
81 | 99 | self.func = func |
|
82 | 100 | |
|
83 | 101 | def __repr__(self): |
@@ -96,6 +114,14 class CoroutineInputTransformer(InputTransformer): | |||
|
96 | 114 | """Wrapper for an input transformer implemented as a coroutine.""" |
|
97 | 115 | def __init__(self, coro, **kwargs): |
|
98 | 116 | # Prime it |
|
117 | super().__init__() | |
|
118 | warnings.warn( | |
|
119 | "`CoroutineInputTransformer` has been deprecated since IPython 7.0" | |
|
120 | " and emit a warnig since IPython 8.31, it" | |
|
121 | " will be removed in the future", | |
|
122 | DeprecationWarning, | |
|
123 | stacklevel=2, | |
|
124 | ) | |
|
99 | 125 | self.coro = coro(**kwargs) |
|
100 | 126 | next(self.coro) |
|
101 | 127 | |
@@ -122,6 +148,13 class TokenInputTransformer(InputTransformer): | |||
|
122 | 148 | return an iterable which can be passed to tokenize.untokenize(). |
|
123 | 149 | """ |
|
124 | 150 | def __init__(self, func): |
|
151 | warnings.warn( | |
|
152 | "`CoroutineInputTransformer` has been deprecated since IPython 7.0" | |
|
153 | " and emit a warnig since IPython 8.31, it" | |
|
154 | " will be removed in the future", | |
|
155 | DeprecationWarning, | |
|
156 | stacklevel=2, | |
|
157 | ) | |
|
125 | 158 | self.func = func |
|
126 | 159 | self.buf = [] |
|
127 | 160 | self.reset_tokenizer() |
@@ -167,7 +200,7 class TokenInputTransformer(InputTransformer): | |||
|
167 | 200 | |
|
168 | 201 | class assemble_python_lines(TokenInputTransformer): |
|
169 | 202 | def __init__(self): |
|
170 |
super( |
|
|
203 | super().__init__(None) | |
|
171 | 204 | |
|
172 | 205 | def output(self, tokens): |
|
173 | 206 | return self.reset() |
@@ -13,7 +13,7 interactive interface. Using them carelessly can easily break IPython! | |||
|
13 | 13 | String based transformations |
|
14 | 14 | ============================ |
|
15 | 15 | |
|
16 | .. currentmodule:: IPython.core.inputtransforms | |
|
16 | .. currentmodule:: IPython.core.inputtransformers2 | |
|
17 | 17 | |
|
18 | 18 | When the user enters code, it is first processed as a string. By the |
|
19 | 19 | end of this stage, it must be valid Python syntax. |
General Comments 0
You need to be logged in to leave comments.
Login now