changeset 10:0b534c8881de

make fetchers a dict keyed on class name
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 18 Sep 2011 18:52:08 -0700
parents f8575a78ec06
children 726c3d288733
files fetch/main.py
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/fetch/main.py	Sun Sep 18 18:47:39 2011 -0700
+++ b/fetch/main.py	Sun Sep 18 18:52:08 2011 -0700
@@ -74,21 +74,20 @@
 ### VCS fetchers using executable
 
 if which('hg'):
-  pass # TODO: wrap HgFetcher
 
-class HgFetcher(Fetcher):
-  """checkout a mercurial repository"""
+  class HgFetcher(Fetcher):
+    """checkout a mercurial repository"""
+    type = 'hg'
 
-  type = 'hg'
+  fetchers.append(HgFetcher)
 
 class GitFetcher(Fetcher):
   """checkout a git repository"""
-
   type = 'git'
 
 
-fetcher_names = [cls.__name__ for cls in fetchers]
-__all__ += fetcher_names
+fetchers = dict([(i.__name__, i) for i in fetchers])
+__all__ += fetchers.keys()
 
 
 class Fetch(object):
@@ -195,7 +194,7 @@
   options, args = parser.parse_args(args)
 
   if options.list_fetchers:
-    for name in fetcher_names:
+    for name in sorted(fetchers.keys()):
       print name
     parser.exit()
 
@@ -204,7 +203,7 @@
     parser.exit()
 
   items = read_manifests(*args)
-  fetch = Fetch(fetchers, strict=options.strict)
+  fetch = Fetch(fetchers.values(), strict=options.strict)
 
   # download the files
   fetch.fetch(*items)