| 1 |
# coding: utf-8 |
| 2 |
|
| 3 |
from __future__ import absolute_import |
| 4 |
|
| 5 |
from strictyaml.ruamel.emitter import Emitter |
| 6 |
from strictyaml.ruamel.serializer import Serializer |
| 7 |
from strictyaml.ruamel.representer import ( |
| 8 |
Representer, |
| 9 |
SafeRepresenter, |
| 10 |
BaseRepresenter, |
| 11 |
RoundTripRepresenter, |
| 12 |
) |
| 13 |
from strictyaml.ruamel.resolver import Resolver, BaseResolver, VersionedResolver |
| 14 |
|
| 15 |
if False: # MYPY |
| 16 |
from typing import Any, Dict, List, Union, Optional # NOQA |
| 17 |
from strictyaml.ruamel.compat import StreamType, VersionType # NOQA |
| 18 |
|
| 19 |
__all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] |
| 20 |
|
| 21 |
|
| 22 |
class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): |
| 23 |
def __init__( |
| 24 |
self, |
| 25 |
stream, |
| 26 |
default_style=None, |
| 27 |
default_flow_style=None, |
| 28 |
canonical=None, |
| 29 |
indent=None, |
| 30 |
width=None, |
| 31 |
allow_unicode=None, |
| 32 |
line_break=None, |
| 33 |
encoding=None, |
| 34 |
explicit_start=None, |
| 35 |
explicit_end=None, |
| 36 |
version=None, |
| 37 |
tags=None, |
| 38 |
block_seq_indent=None, |
| 39 |
top_level_colon_align=None, |
| 40 |
prefix_colon=None, |
| 41 |
): |
| 42 |
# type: (Any, StreamType, Any, Any, Optional[bool], Optional[int], Optional[int], Optional[bool], Any, Any, Optional[bool], Optional[bool], Any, Any, Any, Any, Any) -> None # NOQA |
| 43 |
Emitter.__init__( |
| 44 |
self, |
| 45 |
stream, |
| 46 |
canonical=canonical, |
| 47 |
indent=indent, |
| 48 |
width=width, |
| 49 |
allow_unicode=allow_unicode, |
| 50 |
line_break=line_break, |
| 51 |
block_seq_indent=block_seq_indent, |
| 52 |
dumper=self, |
| 53 |
) |
| 54 |
Serializer.__init__( |
| 55 |
self, |
| 56 |
encoding=encoding, |
| 57 |
explicit_start=explicit_start, |
| 58 |
explicit_end=explicit_end, |
| 59 |
version=version, |
| 60 |
tags=tags, |
| 61 |
dumper=self, |
| 62 |
) |
| 63 |
BaseRepresenter.__init__( |
| 64 |
self, |
| 65 |
default_style=default_style, |
| 66 |
default_flow_style=default_flow_style, |
| 67 |
dumper=self, |
| 68 |
) |
| 69 |
BaseResolver.__init__(self, loadumper=self) |
| 70 |
|
| 71 |
|
| 72 |
class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): |
| 73 |
def __init__( |
| 74 |
self, |
| 75 |
stream, |
| 76 |
default_style=None, |
| 77 |
default_flow_style=None, |
| 78 |
canonical=None, |
| 79 |
indent=None, |
| 80 |
width=None, |
| 81 |
allow_unicode=None, |
| 82 |
line_break=None, |
| 83 |
encoding=None, |
| 84 |
explicit_start=None, |
| 85 |
explicit_end=None, |
| 86 |
version=None, |
| 87 |
tags=None, |
| 88 |
block_seq_indent=None, |
| 89 |
top_level_colon_align=None, |
| 90 |
prefix_colon=None, |
| 91 |
): |
| 92 |
# type: (StreamType, Any, Any, Optional[bool], Optional[int], Optional[int], Optional[bool], Any, Any, Optional[bool], Optional[bool], Any, Any, Any, Any, Any) -> None # NOQA |
| 93 |
Emitter.__init__( |
| 94 |
self, |
| 95 |
stream, |
| 96 |
canonical=canonical, |
| 97 |
indent=indent, |
| 98 |
width=width, |
| 99 |
allow_unicode=allow_unicode, |
| 100 |
line_break=line_break, |
| 101 |
block_seq_indent=block_seq_indent, |
| 102 |
dumper=self, |
| 103 |
) |
| 104 |
Serializer.__init__( |
| 105 |
self, |
| 106 |
encoding=encoding, |
| 107 |
explicit_start=explicit_start, |
| 108 |
explicit_end=explicit_end, |
| 109 |
version=version, |
| 110 |
tags=tags, |
| 111 |
dumper=self, |
| 112 |
) |
| 113 |
SafeRepresenter.__init__( |
| 114 |
self, |
| 115 |
default_style=default_style, |
| 116 |
default_flow_style=default_flow_style, |
| 117 |
dumper=self, |
| 118 |
) |
| 119 |
Resolver.__init__(self, loadumper=self) |
| 120 |
|
| 121 |
|
| 122 |
class Dumper(Emitter, Serializer, Representer, Resolver): |
| 123 |
def __init__( |
| 124 |
self, |
| 125 |
stream, |
| 126 |
default_style=None, |
| 127 |
default_flow_style=None, |
| 128 |
canonical=None, |
| 129 |
indent=None, |
| 130 |
width=None, |
| 131 |
allow_unicode=None, |
| 132 |
line_break=None, |
| 133 |
encoding=None, |
| 134 |
explicit_start=None, |
| 135 |
explicit_end=None, |
| 136 |
version=None, |
| 137 |
tags=None, |
| 138 |
block_seq_indent=None, |
| 139 |
top_level_colon_align=None, |
| 140 |
prefix_colon=None, |
| 141 |
): |
| 142 |
# type: (StreamType, Any, Any, Optional[bool], Optional[int], Optional[int], Optional[bool], Any, Any, Optional[bool], Optional[bool], Any, Any, Any, Any, Any) -> None # NOQA |
| 143 |
Emitter.__init__( |
| 144 |
self, |
| 145 |
stream, |
| 146 |
canonical=canonical, |
| 147 |
indent=indent, |
| 148 |
width=width, |
| 149 |
allow_unicode=allow_unicode, |
| 150 |
line_break=line_break, |
| 151 |
block_seq_indent=block_seq_indent, |
| 152 |
dumper=self, |
| 153 |
) |
| 154 |
Serializer.__init__( |
| 155 |
self, |
| 156 |
encoding=encoding, |
| 157 |
explicit_start=explicit_start, |
| 158 |
explicit_end=explicit_end, |
| 159 |
version=version, |
| 160 |
tags=tags, |
| 161 |
dumper=self, |
| 162 |
) |
| 163 |
Representer.__init__( |
| 164 |
self, |
| 165 |
default_style=default_style, |
| 166 |
default_flow_style=default_flow_style, |
| 167 |
dumper=self, |
| 168 |
) |
| 169 |
Resolver.__init__(self, loadumper=self) |
| 170 |
|
| 171 |
|
| 172 |
class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolver): |
| 173 |
def __init__( |
| 174 |
self, |
| 175 |
stream, |
| 176 |
default_style=None, |
| 177 |
default_flow_style=None, |
| 178 |
canonical=None, |
| 179 |
indent=None, |
| 180 |
width=None, |
| 181 |
allow_unicode=None, |
| 182 |
line_break=None, |
| 183 |
encoding=None, |
| 184 |
explicit_start=None, |
| 185 |
explicit_end=None, |
| 186 |
version=None, |
| 187 |
tags=None, |
| 188 |
block_seq_indent=None, |
| 189 |
top_level_colon_align=None, |
| 190 |
prefix_colon=None, |
| 191 |
): |
| 192 |
# type: (StreamType, Any, Optional[bool], Optional[int], Optional[int], Optional[int], Optional[bool], Any, Any, Optional[bool], Optional[bool], Any, Any, Any, Any, Any) -> None # NOQA |
| 193 |
Emitter.__init__( |
| 194 |
self, |
| 195 |
stream, |
| 196 |
canonical=canonical, |
| 197 |
indent=indent, |
| 198 |
width=width, |
| 199 |
allow_unicode=allow_unicode, |
| 200 |
line_break=line_break, |
| 201 |
block_seq_indent=block_seq_indent, |
| 202 |
top_level_colon_align=top_level_colon_align, |
| 203 |
prefix_colon=prefix_colon, |
| 204 |
dumper=self, |
| 205 |
) |
| 206 |
Serializer.__init__( |
| 207 |
self, |
| 208 |
encoding=encoding, |
| 209 |
explicit_start=explicit_start, |
| 210 |
explicit_end=explicit_end, |
| 211 |
version=version, |
| 212 |
tags=tags, |
| 213 |
dumper=self, |
| 214 |
) |
| 215 |
RoundTripRepresenter.__init__( |
| 216 |
self, |
| 217 |
default_style=default_style, |
| 218 |
default_flow_style=default_flow_style, |
| 219 |
dumper=self, |
| 220 |
) |
| 221 |
VersionedResolver.__init__(self, loader=self) |