Anonymous avatar Anonymous committed a18a1dd

renamed

Comments (0)

Files changed (2)

         return self.zipfile.open(path, mode)
 
 #
-# DistributionDirectory represents a directory that contains egg-info files
+# DistributionDir represents a directory that contains egg-info files
 #
-class DistributionDirectory(set):
+class DistributionDir(set):
 
     def __init__(self, path):
-        super(DistributionDirectory, self).__init__()
+        super(DistributionDir, self).__init__()
         self.path = path
         # filling the list once (see if it's the best way)
         # to minimize I/O
                 self.add(Distribution(fullpath))
 
     def __repr__(self):
-        return 'DistributionDirectory("%s")' % self.path
+        return 'DistributionDir("%s")' % self.path
 
     def add(self, dist):
         """Makes sure only Distribution instances are added."""
         if not isinstance(dist, Distribution):
-            raise TypeError('DistributionDirectory manage only Distribution '
+            raise TypeError('DistributionDir manage only Distribution '
                             'instances')
-        super(DistributionDirectory, self).add(dist)
+        super(DistributionDir, self).add(dist)
 
     #
     # public APIs
                 yield dist
 
 
-class ZippedDistributionDirectory(DistributionDirectory):
+class ZippedDistributionDir(DistributionDir):
 
     def __init__(self, path):
         if not is_zipfile(path):
                     egg_infos.append(paths[0])
 
     def __repr__(self):
-        return 'ZippedDistributionDirectory("%s")' % self.path
+        return 'ZippedDistributionDir("%s")' % self.path
 
     def add(self, dist):
         """Makes sure only Distribution instances are added."""
         if not isinstance(dist, ZippedDistribution):
-            raise TypeError('ZippedDistributionDirectory manage only '
+            raise TypeError('ZippedDistributionDir manage only '
                             'ZippedDistribution instances')
-        super(ZippedDistributionDirectory, self).add(dist)
+        super(ZippedDistributionDir, self).add(dist)
 
 
 #
     _CACHED_DIRS.clear()
 
 
-class DistributionDirectories(dict):
+class DistributionDirMap(dict):
 
     def __init__(self, paths=None, use_cache=True):
-        super(DistributionDirectories, self).__init__()
+        super(DistributionDirMap, self).__init__()
         if paths is not None:
             self.load(*paths)
         self.use_cache = use_cache
 
     def __setitem__(self, path, dir):
-        """Controls the mapping deals only with path/DistributionDirectory"""
+        """Controls the mapping deals only with path/DistributionDir"""
         if not isinstance(path, str):
             raise TypeError('The key needs to be a path')
-        if not isinstance(dir, (ZippedDistributionDirectory,
-                                DistributionDirectory)):
-            raise TypeError('The value needs to be a DistributionDirectory '
-                            'or a ZippedDistributionDirectory instance')
-        super(DistributionDirectories, self).__setitem__(path, dir)
+        if not isinstance(dir, (ZippedDistributionDir,
+                                DistributionDir)):
+            raise TypeError('The value needs to be a DistributionDir '
+                            'or a ZippedDistributionDir instance')
+        super(DistributionDirMap, self).__setitem__(path, dir)
 
     #
     # public APIs
                 dist_dir = _CACHED_DIRS[path]
             else:
                 if is_zipfile(path):
-                    dist_dir = ZippedDistributionDirectory(path)
+                    dist_dir = ZippedDistributionDir(path)
                 else:
-                    dist_dir = DistributionDirectory(path)
+                    dist_dir = DistributionDir(path)
                 if self.use_cache:
                     _CACHED_DIRS[path] = dist_dir
 
                 yield dist
 
 #
-# high level APIs with a global DistributionDirectories instance loaded
+# high level APIs with a global DistributionDirMap instance loaded
 # on sys.path
 #
-_dist_dirs = DistributionDirectories()
+_dist_dirs = DistributionDirMap()
 _dist_dirs.load(*sys.path)
 
 def get_distributions():
     sys.old = sys.path
     sys.path = [SITE_PKG]
     pkgutil.purge_cache()
-    pkgutil._dist_dirs = DistributionDirectories()
+    pkgutil._dist_dirs = DistributionDirMap()
     pkgutil._dist_dirs.load(SITE_PKG)
 
 def teardown():
 
 
 def test_directory():
-    dir = DistributionDirectory(SITE_PKG)
+    dir = DistributionDir(SITE_PKG)
     dist = list(dir.get_file_users('mercurial/filelog.pyc'))[0]
     assert dist.name == 'mercurial'
     assert len(list(dir.get_file_users('mercurial/filelog.py'))) == 2
 
 
 def test_zipped_directory():
-    dir = ZippedDistributionDirectory(SITE_PKG+'.zip')
+    dir = ZippedDistributionDir(SITE_PKG+'.zip')
     dist = list(dir.get_file_users('mercurial/filelog.pyc'))[0]
     assert dist.name == 'mercurial'
     assert len(list(dir.get_file_users('mercurial/filelog.py'))) == 2
     sys.old = sys.path
     sys.path = [SITE_PKG+'.zip']
     pkgutil.purge_cache()
-    pkgutil._dist_dirs = DistributionDirectories()
+    pkgutil._dist_dirs = DistributionDirMap()
     pkgutil._dist_dirs.load(SITE_PKG+'.zip')
 
 @with_setup(setup_zip, teardown)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.