175 else: |
175 else: |
176 token = b'template' |
176 token = b'template' |
177 quote = program[pos : pos + 2] |
177 quote = program[pos : pos + 2] |
178 s = pos = pos + 2 |
178 s = pos = pos + 2 |
179 while pos < end: # find closing escaped quote |
179 while pos < end: # find closing escaped quote |
|
180 # pycompat.bytestr (and bytes) both have .startswith() that |
|
181 # takes an optional start and an optional end, but pytype thinks |
|
182 # it only takes 2 args. |
|
183 |
|
184 # pytype: disable=wrong-arg-count |
180 if program.startswith(b'\\\\\\', pos, end): |
185 if program.startswith(b'\\\\\\', pos, end): |
181 pos += 4 # skip over double escaped characters |
186 pos += 4 # skip over double escaped characters |
182 continue |
187 continue |
183 if program.startswith(quote, pos, end): |
188 if program.startswith(quote, pos, end): |
|
189 # pytype: enable=wrong-arg-count |
|
190 |
184 # interpret as if it were a part of an outer string |
191 # interpret as if it were a part of an outer string |
185 data = parser.unescapestr(program[s:pos]) |
192 data = parser.unescapestr(program[s:pos]) |
186 if token == b'template': |
193 if token == b'template': |
187 data = _parsetemplate(data, 0, len(data))[0] |
194 data = _parsetemplate(data, 0, len(data))[0] |
188 yield (token, data, s) |
195 yield (token, data, s) |
298 if c == quote: |
305 if c == quote: |
299 yield (b'end', None, n + 1) |
306 yield (b'end', None, n + 1) |
300 return |
307 return |
301 |
308 |
302 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop, b'}')) |
309 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop, b'}')) |
|
310 |
|
311 # pycompat.bytestr (and bytes) both have .startswith() that |
|
312 # takes an optional start and an optional end, but pytype thinks |
|
313 # it only takes 2 args. |
|
314 |
|
315 # pytype: disable=wrong-arg-count |
303 if not tmpl.startswith(b'}', pos): |
316 if not tmpl.startswith(b'}', pos): |
|
317 # pytype: enable=wrong-arg-count |
304 raise error.ParseError(_(b"invalid token"), pos) |
318 raise error.ParseError(_(b"invalid token"), pos) |
305 yield (b'template', parseres, n) |
319 yield (b'template', parseres, n) |
306 pos += 1 |
320 pos += 1 |
307 |
321 |
308 if quote: |
322 if quote: |