Emit YAML parsing events into a stream. If stream is None, return the produced string instead.
(events, stream=None, Dumper=Dumper,
canonical=None, indent=None, width=None,
allow_unicode=None, line_break=None)
| 103 | return load_all(stream, SafeLoader) |
| 104 | |
| 105 | def emit(events, stream=None, Dumper=Dumper, |
| 106 | canonical=None, indent=None, width=None, |
| 107 | allow_unicode=None, line_break=None): |
| 108 | """ |
| 109 | Emit YAML parsing events into a stream. |
| 110 | If stream is None, return the produced string instead. |
| 111 | """ |
| 112 | getvalue = None |
| 113 | if stream is None: |
| 114 | stream = io.StringIO() |
| 115 | getvalue = stream.getvalue |
| 116 | dumper = Dumper(stream, canonical=canonical, indent=indent, width=width, |
| 117 | allow_unicode=allow_unicode, line_break=line_break) |
| 118 | try: |
| 119 | for event in events: |
| 120 | dumper.emit(event) |
| 121 | finally: |
| 122 | dumper.dispose() |
| 123 | if getvalue: |
| 124 | return getvalue() |
| 125 | |
| 126 | def serialize_all(nodes, stream=None, Dumper=Dumper, |
| 127 | canonical=None, indent=None, width=None, |
searching dependent graphs…