Show More
@@ -95,6 +95,8 b' def replacetokens(tokens, opts):' | |||
|
95 | 95 | coldelta = 0 # column increment for new opening parens |
|
96 | 96 | coloffset = -1 # column offset for the current line (-1: TBD) |
|
97 | 97 | parens = [(0, 0, 0)] # stack of (line, end-column, column-offset) |
|
98 | ignorenextline = False # don't transform the next line | |
|
99 | insideignoreblock = False # don't transform until turned off | |
|
98 | 100 | for i, t in enumerate(tokens): |
|
99 | 101 | # Compute the column offset for the current line, such that |
|
100 | 102 | # the current line will be aligned to the last opening paren |
@@ -113,6 +115,21 b' def replacetokens(tokens, opts):' | |||
|
113 | 115 | yield adjusttokenpos(t, coloffset) |
|
114 | 116 | coldelta = 0 |
|
115 | 117 | coloffset = -1 |
|
118 | if not insideignoreblock: | |
|
119 | ignorenextline = ( | |
|
120 | tokens[i - 1].type == token.COMMENT | |
|
121 | and tokens[i - 1].string == "#no-py3-transform" | |
|
122 | ) | |
|
123 | continue | |
|
124 | ||
|
125 | if t.type == token.COMMENT: | |
|
126 | if t.string == "#py3-transform: off": | |
|
127 | insideignoreblock = True | |
|
128 | if t.string == "#py3-transform: on": | |
|
129 | insideignoreblock = False | |
|
130 | ||
|
131 | if ignorenextline or insideignoreblock: | |
|
132 | yield adjusttokenpos(t, coloffset) | |
|
116 | 133 | continue |
|
117 | 134 | |
|
118 | 135 | # Remember the last paren position. |
General Comments 0
You need to be logged in to leave comments.
Login now