MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / translate

Method translate

21-async/mojifinder/bottle.py:3485–3509  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3483 syntax = property(get_syntax, set_syntax)
3484
3485 def translate(self):
3486 if self.offset: raise RuntimeError('Parser is a one time instance.')
3487 while True:
3488 m = self.re_split.search(self.source[self.offset:])
3489 if m:
3490 text = self.source[self.offset:self.offset+m.start()]
3491 self.text_buffer.append(text)
3492 self.offset += m.end()
3493 if m.group(1): # New escape syntax
3494 line, sep, _ = self.source[self.offset:].partition('\n')
3495 self.text_buffer.append(m.group(2)+m.group(5)+line+sep)
3496 self.offset += len(line+sep)+1
3497 continue
3498 elif m.group(5): # Old escape syntax
3499 depr('Escape code lines with a backslash.') #0.12
3500 line, sep, _ = self.source[self.offset:].partition('\n')
3501 self.text_buffer.append(m.group(2)+line+sep)
3502 self.offset += len(line+sep)+1
3503 continue
3504 self.flush_text()
3505 self.read_code(multiline=bool(m.group(4)))
3506 else: break
3507 self.text_buffer.append(self.source[self.offset:])
3508 self.flush_text()
3509 return ''.join(self.code_buffer)
3510
3511 def read_code(self, multiline):
3512 code_line, comment = '', ''

Callers 2

codeMethod · 0.95
dewinizeFunction · 0.80

Calls 5

flush_textMethod · 0.95
read_codeMethod · 0.95
deprFunction · 0.85
searchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected