Yield pasted lines until the user enters the given sentinel value.
(sentinel, l_input=py3compat.input, quiet=False)
| 16 | from IPython.utils import py3compat |
| 17 | |
| 18 | def get_pasted_lines(sentinel, l_input=py3compat.input, quiet=False): |
| 19 | """ Yield pasted lines until the user enters the given sentinel value. |
| 20 | """ |
| 21 | if not quiet: |
| 22 | print("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." \ |
| 23 | % sentinel) |
| 24 | prompt = ":" |
| 25 | else: |
| 26 | prompt = "" |
| 27 | while True: |
| 28 | try: |
| 29 | l = l_input(prompt) |
| 30 | if l == sentinel: |
| 31 | return |
| 32 | else: |
| 33 | yield l |
| 34 | except EOFError: |
| 35 | print('<EOF>') |
| 36 | return |
| 37 | |
| 38 | |
| 39 | @magics_class |
no outgoing calls
no test coverage detected
searching dependent graphs…