Commits

ta...@MacZiade.local  committed 7a6f12f

load(paths) -> load(*paths)

  • Participants
  • Parent commits 51ca1c4

Comments (0)

Files changed (2)

             raise TypeError('%s path is not a zipfile' % path)
         self.path = path
         self._zip_file = ZipFile(path)
+        # scanning the zip content
         egg_infos = []
-        # scanning the zip content
         for element in self._zip_file.filelist:
             paths = os.path.split(element.filename)
             if len(paths) < 2:
     def __init__(self, paths=None, use_cache=True):
         super(DistributionDirectories, self).__init__()
         if paths is not None:
-            for path in paths:
-                self.append(path)
+            self.load(*paths)
         self.use_cache = use_cache
 
     def __setitem__(self, path, dir):
     #
     # public APIs
     #
-    def append(self, path):
-        """Appends a path and its corresponding DistributionDirectory."""
-        if self.use_cache and path in _CACHED_DIRS:
-            dist_dir = _CACHED_DIRS[path]
-        else:
-            if is_zipfile(path):
-                dist_dir = ZippedDistributionDirectory(path)
-            else:
-                dist_dir = DistributionDirectory(path)
-            if self.use_cache:
-                _CACHED_DIRS[path] = dist_dir
-
-        self[path] = dist_dir
-
-    def load(self, paths):
+    def load(self, *paths):
         """Loads the paths."""
         for path in paths:
             if path in self or not (os.path.isdir(path) or
                                     is_zipfile(path)):
                 continue
-            self.append(path)
+            if self.use_cache and path in _CACHED_DIRS:
+                dist_dir = _CACHED_DIRS[path]
+            else:
+                if is_zipfile(path):
+                    dist_dir = ZippedDistributionDirectory(path)
+                else:
+                    dist_dir = DistributionDirectory(path)
+                if self.use_cache:
+                    _CACHED_DIRS[path] = dist_dir
+
+            self[path] = dist_dir
 
     def reload(self):
         """Reload all the paths."""
         paths = self.keys()
         self.clear()
-        self.load(paths)
+        self.load(*paths)
 
     def get_distributions(self):
         """Returns an iterator over contained Distribution instances."""
 # on sys.path
 #
 _dist_dirs = DistributionDirectories()
-_dist_dirs.load(sys.path)
+_dist_dirs.load(*sys.path)
 
 def get_distributions():
     """Provides an iterator that returns Distribution instances.

File test_pkgutil.py

     sys.path = [SITE_PKG]
     pkgutil.purge_cache()
     pkgutil._dist_dirs = DistributionDirectories()
-    pkgutil._dist_dirs.load([SITE_PKG])
+    pkgutil._dist_dirs.load(SITE_PKG)
 
 def teardown():
     if not hasattr(sys, 'old'):
 
 def test_zipped_directory():
     dir = ZippedDistributionDirectory(SITE_PKG+'.zip')
-
     dist = dir.owner('mercurial/filelog.pyc')
     assert dist.name == 'mercurial'
     assert dir.owner('mercurial/filelog.py') is None
     sys.path = [SITE_PKG+'.zip']
     pkgutil.purge_cache()
     pkgutil._dist_dirs = DistributionDirectories()
-    pkgutil._dist_dirs.load([SITE_PKG+'.zip'])
+    pkgutil._dist_dirs.load(SITE_PKG+'.zip')
 
 @with_setup(setup_zip, teardown)
 def test_zipped_distribution():