← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/namespace-mergers into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/namespace-mergers into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/namespace-mergers/+merge/159425
-- 
https://code.launchpad.net/~harlowja/cloud-init/namespace-mergers/+merge/159425
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/namespace-mergers into lp:cloud-init.
=== modified file 'cloudinit/mergers/__init__.py'
--- cloudinit/mergers/__init__.py	2013-03-07 22:13:05 +0000
+++ cloudinit/mergers/__init__.py	2013-04-17 15:49:29 +0000
@@ -26,6 +26,8 @@
 
 LOG = logging.getLogger(__name__)
 DEF_MERGE_TYPE = "list()+dict()+str()"
+MERGER_PREFIX = 'm_'
+MERGER_ATTR = 'Merger'
 
 
 class UnknownMerger(object):
@@ -136,15 +138,18 @@
 def construct(parsed_mergers):
     mergers_to_be = []
     for (m_name, m_ops) in parsed_mergers:
+        if not m_name.startswith(MERGER_PREFIX):
+            m_name = MERGER_PREFIX + str(m_name)
         merger_locs = importer.find_module(m_name,
                                            [__name__],
-                                           ['Merger'])
+                                           [MERGER_ATTR])
         if not merger_locs:
-            msg = "Could not find merger named '%s'" % (m_name)
+            msg = ("Could not find merger module named '%s' "
+                   "with attribute '%s'") % (m_name, MERGER_ATTR)
             raise ImportError(msg)
         else:
             mod = importer.import_module(merger_locs[0])
-            mod_attr = getattr(mod, 'Merger')
+            mod_attr = getattr(mod, MERGER_ATTR)
             mergers_to_be.append((mod_attr, m_ops))
     # Now form them...
     mergers = []

=== renamed file 'cloudinit/mergers/dict.py' => 'cloudinit/mergers/m_dict.py'
=== renamed file 'cloudinit/mergers/list.py' => 'cloudinit/mergers/m_list.py'
=== renamed file 'cloudinit/mergers/str.py' => 'cloudinit/mergers/m_str.py'

Follow ups