Commits

Anonymous committed e51e519

simplified APIs

  • Participants
  • Parent commits ce37bd2

Comments (0)

Files changed (1)

 # Directories is a collection of directories, initialized with a
 # list of paths.
 #
+
+_CACHED_DIRS = {}
+
+def purge_cache():
+    _CACHED_DIRS.clear()
+
+
 class EggInfoDirectories(object):
 
-    def __init__(self, paths=sys.path, cacheable=True):
-        self._cacheable = True
-        self._cached_dirs = {}
+    def __init__(self, paths=sys.path, use_cache=True):
         self._paths = []
         self._egg_info_dirs = []
-
-    #
-    # cache managment
-    #
-    def _set_cacheable(self, value):
-        if not value:
-            self._cache_dirs.clear()
-        self._cacheable = value
-
-    def _get_cacheable(self):
-        return self._cacheable
-
-    cacheable = property(_get_cacheable, _set_cacheable)
-
-    def purge_cache(self):
-        self._cached_dirs.clear()
+        self.use_cache = use_cache
 
     #
     # container APIs
     #
     def __iter__(self):
-        return iter(self._egg_infos)
+        return iter(self._egg_info_dirs)
 
     def append(self, egg_info):
         self._egg_info_dirs.append(egg_info)
         self._paths.append(egg_info.path)
-        if self.cacheable:
-            self._cached_dirs[egg_info.path] = egg_info
+        if self.use_cache:
+            _CACHED_DIRS[egg_info.path] = egg_info
 
     def clear(self):
         self._egg_info_dirs.clear()
         for path in paths:
             if path in self._paths:
                 continue
-            if self.cacheable and path in self._cached_dirs:
-                self.append(self._cached_dirs[path])
+            if self.use_cache and path in _CACHED_DIRS:
+                self.append(_CACHED_DIRS[path])
             elif os.path.isdir(path):
                 self.append(EggInfoDirectory(path))