Show More
@@ -26,7 +26,6 b' from IPython.utils.py3compat import cast_unicode' | |||||
26 | from IPython.core.inputtransformer import (leading_indent, |
|
26 | from IPython.core.inputtransformer import (leading_indent, | |
27 | classic_prompt, |
|
27 | classic_prompt, | |
28 | ipy_prompt, |
|
28 | ipy_prompt, | |
29 | strip_encoding_cookie, |
|
|||
30 | cellmagic, |
|
29 | cellmagic, | |
31 | assemble_logical_lines, |
|
30 | assemble_logical_lines, | |
32 | help_end, |
|
31 | help_end, | |
@@ -485,7 +484,6 b' class IPythonInputSplitter(InputSplitter):' | |||||
485 | classic_prompt(), |
|
484 | classic_prompt(), | |
486 | ipy_prompt(), |
|
485 | ipy_prompt(), | |
487 | cellmagic(end_on_blank_line=line_input_checker), |
|
486 | cellmagic(end_on_blank_line=line_input_checker), | |
488 | strip_encoding_cookie(), |
|
|||
489 | ] |
|
487 | ] | |
490 |
|
488 | |||
491 | self.assemble_logical_lines = assemble_logical_lines() |
|
489 | self.assemble_logical_lines = assemble_logical_lines() |
@@ -9,7 +9,6 b' import re' | |||||
9 |
|
9 | |||
10 | from IPython.core.splitinput import LineInfo |
|
10 | from IPython.core.splitinput import LineInfo | |
11 | from IPython.utils import tokenize2 |
|
11 | from IPython.utils import tokenize2 | |
12 | from IPython.utils.openpy import cookie_comment_re |
|
|||
13 | from IPython.utils.py3compat import with_metaclass, PY3 |
|
12 | from IPython.utils.py3compat import with_metaclass, PY3 | |
14 | from IPython.utils.tokenize2 import generate_tokens, untokenize, TokenError |
|
13 | from IPython.utils.tokenize2 import generate_tokens, untokenize, TokenError | |
15 |
|
14 | |||
@@ -505,29 +504,6 b' def leading_indent():' | |||||
505 | line = (yield line) |
|
504 | line = (yield line) | |
506 |
|
505 | |||
507 |
|
506 | |||
508 | @CoroutineInputTransformer.wrap |
|
|||
509 | def strip_encoding_cookie(): |
|
|||
510 | """Remove encoding comment if found in first two lines |
|
|||
511 |
|
||||
512 | If the first or second line has the `# coding: utf-8` comment, |
|
|||
513 | it will be removed. |
|
|||
514 | """ |
|
|||
515 | line = '' |
|
|||
516 | while True: |
|
|||
517 | line = (yield line) |
|
|||
518 | # check comment on first two lines |
|
|||
519 | for i in range(2): |
|
|||
520 | if line is None: |
|
|||
521 | break |
|
|||
522 | if cookie_comment_re.match(line): |
|
|||
523 | line = (yield "") |
|
|||
524 | else: |
|
|||
525 | line = (yield line) |
|
|||
526 |
|
||||
527 | # no-op on the rest of the cell |
|
|||
528 | while line is not None: |
|
|||
529 | line = (yield line) |
|
|||
530 |
|
||||
531 | _assign_pat = \ |
|
507 | _assign_pat = \ | |
532 | r'''(?P<lhs>(\s*) |
|
508 | r'''(?P<lhs>(\s*) | |
533 | ([\w\.]+) # Initial identifier |
|
509 | ([\w\.]+) # Initial identifier |
@@ -78,13 +78,6 b' syntax = \\' | |||||
78 | (' ',' '), # blank lines are kept intact |
|
78 | (' ',' '), # blank lines are kept intact | |
79 | ], |
|
79 | ], | |
80 |
|
80 | |||
81 | strip_encoding_cookie = |
|
|||
82 | [ |
|
|||
83 | ('# -*- encoding: utf-8 -*-', ''), |
|
|||
84 | ('# coding: latin-1', ''), |
|
|||
85 | ], |
|
|||
86 |
|
||||
87 |
|
||||
88 | # Tests for the escape transformer to leave normal code alone |
|
81 | # Tests for the escape transformer to leave normal code alone | |
89 | escaped_noesc = |
|
82 | escaped_noesc = | |
90 | [ (' ', ' '), |
|
83 | [ (' ', ' '), | |
@@ -255,20 +248,6 b' syntax_ml = \\' | |||||
255 | ], |
|
248 | ], | |
256 | ], |
|
249 | ], | |
257 |
|
250 | |||
258 | strip_encoding_cookie = |
|
|||
259 | [ |
|
|||
260 | [ |
|
|||
261 | ('# -*- coding: utf-8 -*-', ''), |
|
|||
262 | ('foo', 'foo'), |
|
|||
263 | ], |
|
|||
264 | [ |
|
|||
265 | ('#!/usr/bin/env python', '#!/usr/bin/env python'), |
|
|||
266 | ('# -*- coding: latin-1 -*-', ''), |
|
|||
267 | # only the first-two lines |
|
|||
268 | ('# -*- coding: latin-1 -*-', '# -*- coding: latin-1 -*-'), |
|
|||
269 | ], |
|
|||
270 | ], |
|
|||
271 |
|
||||
272 | multiline_datastructure_prompt = |
|
251 | multiline_datastructure_prompt = | |
273 | [ [('>>> a = [1,','a = [1,'), |
|
252 | [ [('>>> a = [1,','a = [1,'), | |
274 | ('... 2]','2]'), |
|
253 | ('... 2]','2]'), | |
@@ -379,11 +358,6 b' def test_ipy_prompt():' | |||||
379 | (u'In [1]: bar', 'In [1]: bar'), |
|
358 | (u'In [1]: bar', 'In [1]: bar'), | |
380 | ], ipt.ipy_prompt) |
|
359 | ], ipt.ipy_prompt) | |
381 |
|
360 | |||
382 | def test_coding_cookie(): |
|
|||
383 | tt.check_pairs(transform_and_reset(ipt.strip_encoding_cookie), syntax['strip_encoding_cookie']) |
|
|||
384 | for example in syntax_ml['strip_encoding_cookie']: |
|
|||
385 | transform_checker(example, ipt.strip_encoding_cookie) |
|
|||
386 |
|
||||
387 | def test_assemble_logical_lines(): |
|
361 | def test_assemble_logical_lines(): | |
388 | tests = \ |
|
362 | tests = \ | |
389 | [ [(u"a = \\", None), |
|
363 | [ [(u"a = \\", None), |
General Comments 0
You need to be logged in to leave comments.
Login now