[Checkins] SVN: zc.buildout/branches/help-api/src/zc/buildout/ give help on specific version

Tarek Ziade ziade.tarek at gmail.com
Wed Jan 23 17:31:02 EST 2008


Log message for revision 83142:
  give help on specific version

Changed:
  U   zc.buildout/branches/help-api/src/zc/buildout/buildout.py
  U   zc.buildout/branches/help-api/src/zc/buildout/tests.py

-=-
Modified: zc.buildout/branches/help-api/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2008-01-23 22:29:57 UTC (rev 83141)
+++ zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2008-01-23 22:31:02 UTC (rev 83142)
@@ -154,6 +154,7 @@
         self.newest = newest == 'true'
 
         versions = options.get('versions')
+        self.versions = versions
         if versions:
             zc.buildout.easy_install.default_versions(dict(self[versions]))
 
@@ -802,19 +803,50 @@
         return iter(self._raw)
 
     def describe(self, recipes):
-        for recipe_spec in recipes:
+        for recipe in recipes:
+            recipe_spec = self._compute_recipe_and_version(recipe)
             recipe_class = self._get_recipe_class(recipe_spec)
+            if self.multiple_entry_points(recipe_spec):
+                return
             if recipe_class is not None:
-                self._describe_recipe(recipe_spec, recipe_class)
+                self._describe_recipe(recipe, recipe_class)
 
+    def multiple_entry_points(self, name):
+        entry_points = list(pkg_resources.iter_entry_points(
+                'zc.buildout', name))
+        if len(entry_points) > 1:
+            print '%s has multiple entry points:' % name
+            for entry_point in entry_points:
+                print entry_point
+            print
+            print "To get help about one of them use 'buildout",
+            print "describe %s:xxx'." % name
+            return True
+        else:
+            return False
+
     def _get_recipe_class(self, name):
-        # XXX no version specified yet
         try:
             reqs, entry = _recipe({'recipe': name})
             return  _install_and_load(reqs, 'zc.buildout', entry, self)
         except pkg_resources.DistributionNotFound:
             return None
 
+    def _compute_recipe_and_version(self, name):
+        #if the recipe version is specified in versions section,
+        #do nothing
+        if self.versions and name in self[self.versions].keys():
+            return name
+        else:
+            #iterate parts recipes
+            parts = self['buildout']['parts'].split()
+            recipes = [self[part]['recipe'] for part in parts]
+            for recipe in recipes:
+            #and use first recipe name that holds a version spec
+                if name in recipe:
+                    return recipe
+        return name
+
     def _describe_recipe(self, name, recipe_class):
         docstring = recipe_class.__doc__
         if docstring is not None:

Modified: zc.buildout/branches/help-api/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/tests.py	2008-01-23 22:29:57 UTC (rev 83141)
+++ zc.buildout/branches/help-api/src/zc/buildout/tests.py	2008-01-23 22:31:02 UTC (rev 83142)
@@ -713,7 +713,7 @@
         The coolest recipe on Earth.
     <BLANKLINE>
 
-    Let's add a second recipe in the egg:
+    Let's add a second entry point in the recipe:
 
     >>> write(sample_buildout, 'my.recipes', 'setup.py',
     ... '''
@@ -760,7 +760,15 @@
     <BLANKLINE>
 
     >>> print system('%s describe my.recipes' % buildout) 
-    my.recipes
+    my.recipes has multiple entry points:
+        default
+        second
+    <BLANKLINE>
+    To get help about one of them use 'buildout describe my.recipes:xxx'.
+    <BLANKLINE>
+
+    >>> print system('%s describe my.recipes:default' % buildout) 
+    my.recipes:default
         The coolest recipe on Earth.
     <BLANKLINE>
 
@@ -769,8 +777,15 @@
         Help not available
     <BLANKLINE>
 
+    >>> print system('%s describe my.recipes:default my.recipes:second' % buildout) 
+    my.recipes:default
+        The coolest recipe on Earth.
+    my.recipes:second
+        Help not available
+    <BLANKLINE>
 
 
+
     """
 
 def test_describe_versions():
@@ -903,7 +918,6 @@
     ... ''')
 
     >>> print system('%s describe my.recipes' % buildout) 
-    Couldn't find index page for 'my.recipes' (maybe misspelled?)
     my.recipes
         my.recipes 0.1.4
     <BLANKLINE>
@@ -917,7 +931,6 @@
     ... ''')
 
     >>> print system('%s describe my.recipes' % buildout) 
-    Couldn't find index page for 'my.recipes' (maybe misspelled?)
     my.recipes
         my.recipes 0.1.3
     <BLANKLINE>
@@ -941,8 +954,23 @@
         my.recipes 0.1.3
     <BLANKLINE>
 
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = my-recipe
+    ... versions = versions
+    ... [versions]
+    ... my.recipes = 0.1.4
+    ... [my-recipe]
+    ... recipe = my.recipes
+    ... ''')
 
+    >>> print system('%s describe my.recipes' % buildout) 
+    my.recipes
+        my.recipes 0.1.4
+    <BLANKLINE>
 
+
     """
 
 



More information about the Checkins mailing list