From d90a2b356e7db1a3d0e0e818c89482f9f4a96624 Mon Sep 17 00:00:00 2001 From: Reto Zingg Date: Thu, 25 Jun 2020 16:14:28 +0300 Subject: [PATCH] Allow indent, width and block_seq_indent in as_yaml The used dumper StrictYAMLDumper inherits this options, so expose them also in as_yaml() --- strictyaml/representation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/strictyaml/representation.py b/strictyaml/representation.py index 3545ece..daf8b5a 100644 --- a/strictyaml/representation.py +++ b/strictyaml/representation.py @@ -247,11 +247,13 @@ def __hash__(self): def __len__(self): return len(self._value) - def as_yaml(self): + def as_yaml(self, indent=None, width=None, block_seq_indent=None): """ Render the YAML node and subnodes as string. """ - dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, allow_unicode=True) + dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, + allow_unicode=True, indent=indent, + width=width, block_seq_indent=block_seq_indent) return dumped if sys.version_info[0] == 3 else dumped.decode("utf8") def items(self):