| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 13dc706 commit b292711
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,10 @@ | |||
| 2 | 2 | etc)""" | |
| 3 | 3 | ||
| 4 | 4 | from ..lazyre import LazyReCompile | |
| 5 | + from itertools import tee, islice, chain | ||
| 5 | 6 | ||
| 6 | 7 | # TODO specifically catch IndentationErrors instead of any syntax errors | |
| 7 | 8 | ||
| 8 | - | ||
| 9 | 9 | indent_empty_lines_re = LazyReCompile(r"\s*") | |
| 10 | 10 | tabs_to_spaces_re = LazyReCompile(r"^\t+") | |
| 11 | 11 | ||
@@ -21,7 +21,11 @@ def indent_empty_lines(s, compiler): | |||
| 21 | 21 | lines.pop() | |
| 22 | 22 | result_lines = [] | |
| 23 | 23 | ||
| 24 | - for p_line, line, n_line in zip([""] + lines[:-1], lines, lines[1:] + [""]): | ||
| 24 | + prevs, lines, nexts = tee(lines, 3) | ||
| 25 | + prevs = chain(("",), prevs) | ||
| 26 | + nexts = chain(islice(nexts, 1, None), ("",)) | ||
| 27 | + | ||
| 28 | + for p_line, line, n_line in zip(prevs, lines, nexts): | ||
| 25 | 29 | if len(line) == 0: | |
| 26 | 30 | p_indent = indent_empty_lines_re.match(p_line).group() | |
| 27 | 31 | n_indent = indent_empty_lines_re.match(n_line).group() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments