##// END OF EJS Templates
byteify-strings: add support for ignore comments...
Raphaël Gomès -
r42906:b9a20047 default
parent child Browse files
Show More
@@ -95,6 +95,8 b' def replacetokens(tokens, opts):'
95 coldelta = 0 # column increment for new opening parens
95 coldelta = 0 # column increment for new opening parens
96 coloffset = -1 # column offset for the current line (-1: TBD)
96 coloffset = -1 # column offset for the current line (-1: TBD)
97 parens = [(0, 0, 0)] # stack of (line, end-column, column-offset)
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 for i, t in enumerate(tokens):
100 for i, t in enumerate(tokens):
99 # Compute the column offset for the current line, such that
101 # Compute the column offset for the current line, such that
100 # the current line will be aligned to the last opening paren
102 # the current line will be aligned to the last opening paren
@@ -113,6 +115,21 b' def replacetokens(tokens, opts):'
113 yield adjusttokenpos(t, coloffset)
115 yield adjusttokenpos(t, coloffset)
114 coldelta = 0
116 coldelta = 0
115 coloffset = -1
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 continue
133 continue
117
134
118 # Remember the last paren position.
135 # Remember the last paren position.
General Comments 0
You need to be logged in to leave comments. Login now