r"""Read a block of text. A block is what typically follows a for or it statement. It can be in the same line as that of the statement or an indented block. >>> read_indented_block = Parser().read_indented_block >>> read_indented_block(' a\n b\nc', ' ')
(self, text, indent)
| 404 | return [t[1] for t in tokens] |
| 405 | |
| 406 | def read_indented_block(self, text, indent): |
| 407 | r"""Read a block of text. A block is what typically follows a for or it statement. |
| 408 | It can be in the same line as that of the statement or an indented block. |
| 409 | |
| 410 | >>> read_indented_block = Parser().read_indented_block |
| 411 | >>> read_indented_block(' a\n b\nc', ' ') |
| 412 | ('a\nb\n', 'c') |
| 413 | >>> read_indented_block(' a\n b\n c\nd', ' ') |
| 414 | ('a\n b\nc\n', 'd') |
| 415 | >>> read_indented_block(' a\n\n b\nc', ' ') |
| 416 | ('a\n\n b\n', 'c') |
| 417 | """ |
| 418 | if indent == "": |
| 419 | return "", text |
| 420 | |
| 421 | block = "" |
| 422 | while text: |
| 423 | line, text2 = splitline(text) |
| 424 | if line.strip() == "": |
| 425 | block += "\n" |
| 426 | elif line.startswith(indent): |
| 427 | block += line[len(indent) :] |
| 428 | else: |
| 429 | break |
| 430 | text = text2 |
| 431 | return block, text |
| 432 | |
| 433 | def read_statement(self, text): |
| 434 | r"""Reads a python statement. |
no test coverage detected