diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-03-06 19:24:05 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-03-06 19:24:05 -0800 |
commit | fc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1 (patch) | |
tree | baf2534ea20b011e2b9d68ffdd5385ecba2dc31f /cloudinit/mergers | |
parent | 2653a9172e375484b4d0a88c3de56334136fa134 (diff) | |
download | vyos-cloud-init-fc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1.tar.gz vyos-cloud-init-fc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1.zip |
Continue working on merging code.
Diffstat (limited to 'cloudinit/mergers')
-rw-r--r-- | cloudinit/mergers/__init__.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cloudinit/mergers/__init__.py b/cloudinit/mergers/__init__.py index 4a112165..453426af 100644 --- a/cloudinit/mergers/__init__.py +++ b/cloudinit/mergers/__init__.py @@ -20,11 +20,12 @@ import re from cloudinit import importer from cloudinit import log as logging -from cloudinit import util +from cloudinit import type_utils NAME_MTCH = re.compile(r"(^[a-zA-Z_][A-Za-z0-9_]*)\((.*?)\)$") LOG = logging.getLogger(__name__) +DEF_MERGE_TYPE = "list(extend)+dict()+str(append)" class UnknownMerger(object): @@ -42,7 +43,7 @@ class UnknownMerger(object): # If not found the merge will be given to a '_handle_unknown' # function which can decide what to do wit the 2 values. def merge(self, source, merge_with): - type_name = util.obj_name(source) + type_name = type_utils.obj_name(source) type_name = type_name.lower() method_name = "_on_%s" % (type_name) meth = None @@ -127,6 +128,10 @@ def string_extract_mergers(merge_how): return parsed_mergers +def default_mergers(): + return tuple(string_extract_mergers(DEF_MERGE_TYPE)) + + def construct(parsed_mergers): mergers_to_be = [] for (m_name, m_ops) in parsed_mergers: @@ -145,4 +150,6 @@ def construct(parsed_mergers): root = LookupMerger(mergers) for (attr, opts) in mergers_to_be: mergers.append(attr(root, opts)) - return root
\ No newline at end of file + return root + + |