summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 25a60c52..e0ef6ee0 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -144,16 +144,13 @@ class Distro(object):
return False
-def fetch(distro_name, mods=(__name__, )):
- mod = None
- for m in mods:
- mod_name = "%s.%s" % (m, distro_name)
- try:
- mod = importer.import_module(mod_name)
- except ImportError:
- pass
- if not mod:
- raise RuntimeError("No distribution found for distro %s"
- % (distro_name))
- distro_cls = getattr(mod, 'Distro')
- return distro_cls
+def fetch(name):
+ locs = importer.find_module(name,
+ ['', __name__],
+ ['Distro'])
+ if not locs:
+ raise ImportError("No distribution found for distro %s"
+ % (name))
+ mod = importer.import_module(locs[0])
+ cls = getattr(mod, 'Distro')
+ return cls