Anonymous committed 1e445b0

better docstrings

  • Participants
  • Parent commits d6ba14e

Comments (0)

Files changed (1)

         return 'DistributionDirectory("%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 '
     # public APIs
     def append(self, path):
-        """Appends a path."""
+        """Appends a path and its corresponding DistributionDirectory."""
         if self.use_cache and path in _CACHED_DIRS:
             dist_dir = _CACHED_DIRS[path]
         self[path] = dist_dir
     def load(self, paths):
+        """Loads the paths."""
         for path in paths:
             if path in self or not os.path.isdir(path):
     def reload(self):
+        """Reload all the paths."""
         paths = self.keys()
     def get_distributions(self):
+        """Returns an iterator over contained Distribution instances."""
         for directory in self.values():
             for dist in directory:
                 yield dist
     def get_distribution(self, project_name):
-        """Returns an EggInfo instance for the given project name.
+        """Returns an Distribution instance for the given project name.
         If not found, returns None.
     def get_file_users(self, path):
         """Iterates over all projects to find out which project uses the file.
-        Return EggInfo instances.
+        Return Distribution instances.
         for directory in self.values():
             for dist in directory.file_users(path):
 def get_distributions():
+    """Provides an iterator that returns Distribution instances.
+    Looks for `.egg-info` directories in `sys.path` and returns Distribution
+    instances for each one of them.
+    """
     return _dist_dirs.get_distributions()
-def get_distribution(project_name):
+def get_distribution(name):
+    """Returns a ``Distribution`` instance for ``name``.
+    Scans all elements in `sys.path` and looks for all directories ending
+    with `.egg-info`. Returns a ``Distribution`` instance corresponding to
+    the `.egg-info` directory that contains a `PKG-INFO` that matches
+    ``name`` for the ``name`` metadata.
+    Notice that there should be at most one result. The first result
+    founded will be returned. If the directory is not found, returns ``None``.
+    """
     return _dist_dirs.get_distribution(project_name)
 def get_file_users(path):
+    """Iterates over all distributions to find out which distribution uses
+    ``path``.
+    ``path`` can be a local absolute path or a relative '/'-separated path.
+    """
     return _dist_dirs.get_file_users(path)