You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

221 line
6.5 KiB

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