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

Method flush_text

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

Source from the content-addressed store, hash-verified

3556 break
3557
3558 def flush_text(self):
3559 text = ''.join(self.text_buffer)
3560 del self.text_buffer[:]
3561 if not text: return
3562 parts, pos, nl = [], 0, '\\\n'+' '*self.indent
3563 for m in self.re_inl.finditer(text):
3564 prefix, pos = text[pos:m.start()], m.end()
3565 if prefix:
3566 parts.append(nl.join(map(repr, prefix.splitlines(True))))
3567 if prefix.endswith('\n'): parts[-1] += nl
3568 parts.append(self.process_inline(m.group(1).strip()))
3569 if pos < len(text):
3570 prefix = text[pos:]
3571 lines = prefix.splitlines(True)
3572 if lines[-1].endswith('\\\\\n'): lines[-1] = lines[-1][:-3]
3573 elif lines[-1].endswith('\\\\\r\n'): lines[-1] = lines[-1][:-4]
3574 parts.append(nl.join(map(repr, lines)))
3575 code = '_printlist((%s,))' % ', '.join(parts)
3576 self.lineno += code.count('\n')+1
3577 self.write_code(code)
3578
3579 def process_inline(self, chunk):
3580 if chunk[0] == '!': return '_str(%s)' % chunk[1:]

Callers 1

translateMethod · 0.95

Calls 3

process_inlineMethod · 0.95
write_codeMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected