Don't clear the category after the initial package.
authorW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 22:29:09 +0000 (18:29 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 22:29:09 +0000 (18:29 -0400)
My previous implementation actually set the category to the empty
string, which is definately not what we want.  The current
implementation checks both the specified category and dev-python when
looking for required packages, and defaults to generating all required
packages in the specified category.

The literal set syntax `{a,b,...}` requires Python >= 2.7, but that's
the current default in Portage, so anyone running g-pypi should have
it already.

g_pypi/cli.py

index 8bc61ee7f5bdc32bab258b0b135bf7092ae9f0bf..78eb79c53c26f2ad7d67c76b74771d943811218b 100755 (executable)
@@ -131,6 +131,7 @@ class GPyPI(object):
         #ebuild already exists
         #self.logger.debug("Creating dep tree...")
         no_deps = self.config.getboolean('options', 'no_deps')
+        category = self.config.get('options', 'category')
         while len(self.tree):
             (project_name, version) = self.tree.pop(0)
             #self.logger.debug(self.tree)
@@ -141,14 +142,23 @@ class GPyPI(object):
             #print "REQUIRES", requires
             if requires:
                 for req in requires:
-                    if no_deps or ebuild_exists("dev-python/%s" % req.project_name.lower()):
-                        if not no_deps:
-                            self.logger.info("Skipping dependency (exists): %s" % req.project_name)
+                    depcat = None
+                    for cat in {category, 'dev-python'}:
+                        if ebuild_exists('%s/%s' % (
+                                category, req.project_name.lower())):
+                            depcat = cat
+                            break
+                    if depcat:
+                        self.logger.info(
+                            'skipping dependency (exists): %s/%s' % (
+                                depcat, req.project_name))
+                    elif no_deps:
+                        self.logger.info(
+                            'skipping dependency: %s' % req.project_name)
                     else:
                         self.add_dep(req.project_name)
-            #Only force overwriting and category on first ebuild created, not dependencies
+            #Only force overwriting on first ebuild created, not dependencies
             self.config.setboolean('options', 'overwrite', False)
-            self.config.set('options', 'category', '')
 
     def add_dep(self, project_name):
         '''Add dependency'''