From 0eabf9cdc2870982bcabc6e5d05c80078fa100cb Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 18 Apr 2013 13:29:39 -0700 Subject: Adjust how merging is done. --- cloudinit/mergers/list.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'cloudinit/mergers/list.py') diff --git a/cloudinit/mergers/list.py b/cloudinit/mergers/list.py index a56ff007..7c8b2e2a 100644 --- a/cloudinit/mergers/list.py +++ b/cloudinit/mergers/list.py @@ -20,7 +20,6 @@ class Merger(object): def __init__(self, merger, opts): self._merger = merger - self._discard_non = 'discard_non_list' in opts self._extend = 'extend' in opts def _on_tuple(self, value, merge_with): @@ -33,18 +32,7 @@ class Merger(object): # attempt to merge instead, which means that values from the list # to merge with will replace values in te original list (they will # also be merged recursively). - # - # If the value to merge with is not a list, and we are set to discared - # then no modifications will take place, otherwise we will just append - # the value to merge with onto the end of our own list. def _on_list(self, value, merge_with): - new_value = list(value) - if isinstance(merge_with, (tuple, list)): - if self._extend: - new_value.extend(merge_with) - else: - return new_value - else: - if not self._discard_non: - new_value.append(merge_with) - return new_value + if not self._extend or not isinstance(merge_with, (tuple, list)): + return merge_with + return list(value).extend(merge_with) -- cgit v1.2.3