Commits

jtor14  committed 36c563e Draft

Expose indentless to dump functions.

  • Participants
  • Parent commits 8046233

Comments (0)

Files changed (3)

File lib/yaml/__init__.py

         canonical=None, indent=None, width=None,
         allow_unicode=None, line_break=None,
         encoding='utf-8', explicit_start=None, explicit_end=None,
-        version=None, tags=None):
+             version=None, tags=None, indentless=None):
     """
     Serialize a sequence of Python objects into a YAML stream.
     If stream is None, return the produced string instead.
             canonical=canonical, indent=indent, width=width,
             allow_unicode=allow_unicode, line_break=line_break,
             encoding=encoding, version=version, tags=tags,
-            explicit_start=explicit_start, explicit_end=explicit_end)
+                    explicit_start=explicit_start, explicit_end=explicit_end,
+                    indentless=indentless)
     try:
         dumper.open()
         for data in documents:

File lib/yaml/dumper.py

             canonical=None, indent=None, width=None,
             allow_unicode=None, line_break=None,
             encoding=None, explicit_start=None, explicit_end=None,
-            version=None, tags=None):
+                 version=None, tags=None, indentless=None):
         Emitter.__init__(self, stream, canonical=canonical,
                 indent=indent, width=width,
-                allow_unicode=allow_unicode, line_break=line_break)
+                allow_unicode=allow_unicode, line_break=line_break, indentless=indentless)
         Serializer.__init__(self, encoding=encoding,
                 explicit_start=explicit_start, explicit_end=explicit_end,
                 version=version, tags=tags)
             canonical=None, indent=None, width=None,
             allow_unicode=None, line_break=None,
             encoding=None, explicit_start=None, explicit_end=None,
-            version=None, tags=None):
+                 version=None, tags=None, indentless=None):
         Emitter.__init__(self, stream, canonical=canonical,
                 indent=indent, width=width,
-                allow_unicode=allow_unicode, line_break=line_break)
+                allow_unicode=allow_unicode, line_break=line_break, indentless=indentless)
         Serializer.__init__(self, encoding=encoding,
                 explicit_start=explicit_start, explicit_end=explicit_end,
                 version=version, tags=tags)
             canonical=None, indent=None, width=None,
             allow_unicode=None, line_break=None,
             encoding=None, explicit_start=None, explicit_end=None,
-            version=None, tags=None):
+                 version=None, tags=None, indentless=None):
         Emitter.__init__(self, stream, canonical=canonical,
                 indent=indent, width=width,
-                allow_unicode=allow_unicode, line_break=line_break)
+                         allow_unicode=allow_unicode, line_break=line_break, indentless=indentless)
         Serializer.__init__(self, encoding=encoding,
                 explicit_start=explicit_start, explicit_end=explicit_end,
                 version=version, tags=tags)

File lib/yaml/emitter.py

-
 # Emitter expects events obeying the following grammar:
 # stream ::= STREAM-START document* STREAM-END
 # document ::= DOCUMENT-START node DOCUMENT-END
     }
 
     def __init__(self, stream, canonical=None, indent=None, width=None,
-            allow_unicode=None, line_break=None):
+                 allow_unicode=None, line_break=None, indentless=None):
 
         # The stream should have the methods `write` and possibly `flush`.
         self.stream = stream
         self.open_ended = False
 
         # Formatting details.
+        self.indentless = indentless
         self.canonical = canonical
         self.allow_unicode = allow_unicode
         self.best_indent = 2
     # Block sequence handlers.
 
     def expect_block_sequence(self):
-        indentless = (self.mapping_context and not self.indention)
+        if self.indentless is None:
+            indentless = True
+        else:
+            indentless = self.indentless
         self.increase_indent(flow=False, indentless=indentless)
         self.state = self.expect_first_block_sequence_item