Added yaml class dumper to support indentation
The default py yaml `safe_dumps` keeps to the yaml spec which states incremental indentations are not required. Sadly, without the indentations some consumers of yaml configurations files will break. This commit adds an incremental indentation dumper to cater for all yaml configuration consumers. Change-Id: Ifa5bcc6ff9f0a9cb5e619e62d0356f5d6887ca6e Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
b78bf8ce43
commit
80d59cdf96
@ -73,6 +73,11 @@ def _convert_2_string(item):
|
||||
return str(item)
|
||||
|
||||
|
||||
class IDumper(yaml.SafeDumper):
|
||||
def increase_indent(self, flow=False, indentless=False):
|
||||
return super(IDumper, self).increase_indent(flow, False)
|
||||
|
||||
|
||||
class MultiKeyDict(dict):
|
||||
"""Dictionary class which supports duplicate keys.
|
||||
This class allows for an item to be added into a standard python dictionary
|
||||
@ -374,8 +379,9 @@ class ActionModule(ActionBase):
|
||||
new_items=config_overrides,
|
||||
list_extend=list_extend
|
||||
)
|
||||
return yaml.safe_dump(
|
||||
return yaml.dump(
|
||||
merged_resultant,
|
||||
Dumper=IDumper,
|
||||
default_flow_style=False,
|
||||
width=1000,
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
list_one:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- four
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- four
|
||||
list_two:
|
||||
- one
|
||||
- two
|
||||
- one
|
||||
- two
|
||||
|
@ -1,5 +1,5 @@
|
||||
list_one:
|
||||
- four
|
||||
- four
|
||||
list_two:
|
||||
- one
|
||||
- two
|
||||
- one
|
||||
- two
|
||||
|
Loading…
Reference in New Issue
Block a user