From 0d6ec0d9547ac95980d4444aa70216312455e837 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Tue, 12 Jan 2016 11:42:09 -0500 Subject: Fix for to_padded_yaml filter - Fix issue where None is passed to to_padded_yaml filter and invalid config is generated. --- filter_plugins/oo_filters.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'filter_plugins') diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index c262693ec..671c237b9 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -479,6 +479,9 @@ class FilterModule(object): @staticmethod def to_padded_yaml(data, level=0, indent=2, **kw): ''' returns a yaml snippet padded to match the indent level you specify ''' + if data in [None, ""]: + return "" + try: transformed = yaml.safe_dump(data, indent=indent, allow_unicode=True, default_flow_style=False, **kw) padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()]) -- cgit v1.2.1