]> git.donarmstrong.com Git - neurodebian.git/commitdiff
Robustify changes for new package lists.
authorMichael Hanke <michael.hanke@gmail.com>
Tue, 22 Mar 2011 18:52:57 +0000 (14:52 -0400)
committerMichael Hanke <michael.hanke@gmail.com>
Tue, 22 Mar 2011 18:52:57 +0000 (14:52 -0400)
neurodebian/dde.py
sphinx/_templates/layout.html
sphinx/index.rst

index f0f43c7f5caa075717edf4bfce2a9d78a157e71a..d1de917f5a52c3def586dc6a8e71ddb7b5367b03 100755 (executable)
@@ -703,31 +703,45 @@ def sort_by_tasks(db):
 
 def sort_by_maintainer(db):
     maints = {}
+    maint_ids = {}
     for pkg in db.keys():
-        if not 'main' in db[pkg]:
+        maint = None
+        pkginfo = db[pkg]
+        # start with the blends info
+        if 'blends' in pkginfo and 'responsible' in pkginfo['blends']:
+            maint = pkginfo['blends']['responsible']
+        if not 'main' in db[pkg] and maint is None:
             # no info
             continue
         info = db[pkg]['main']
-        if not 'maintainer' in info:
+        if not 'maintainer' in info and maint is None:
             # no maintainer info
             continue
         if 'original_maintainer' in info and not info['original_maintainer'] is None:
             maint = info['original_maintainer']
-        else:
+        elif 'maintainer' in info and not info['maintainer'] is None:
             maint = info['maintainer']
         if maint is None:
             # no sane maintainer info
             continue
         # safeguard: <> confuses sphinx and we don't care about different emails
         maint = maint[:maint.find('<')].strip()
-        if not maint in maints:
-            maints[maint] = []
+        # kick out non-ascii ones (should not be, but too tired to find the bug)
+        try:
+            codecs.ascii_decode(maint)
+        except UnicodeEncodeError:
+            continue
+        if not maint.lower() in maints:
+            maints[maint.lower()] = []
+            maint_ids[maint.lower()] = [maint]
         else:
-            maints[maint].append(pkg)
+            maint_ids[maint.lower()].append(maint)
+        maints[maint.lower()].append(pkg)
     # remove duplicates
+    out = {}
     for m in maints:
-        maints[m] = np.unique(maints[m])
-    return maints
+        out[maint_ids[m][0]] = np.unique(maints[m])
+    return out
 
 
 def sort_by_release(db):
@@ -770,29 +784,21 @@ def write_pkgpages(jinja_env, cfg, db, outdir, addenum_dir, extracts_dir):
         ids.sort()
         for id_ in ids:
             label = ('pkgs-%s-%s' % (sectitle, id_)).lower().replace(' ', '_').replace('/', '_')
-            if not len(pkgsdict[id_]):
+            # filter out crap
+            filtered_pkgs = [p for p in pkgsdict[id_] if p in db]
+            if not len(filtered_pkgs):
                 continue
-            try:
-                plist = toc_template.render(
-                            label=label,
-                            title=underline_text(title_tmpl % id_, '='),
-                            pkgs=pkgsdict[id_],
-                            db=db)
-                if not plist:
-                    continue
-                toc = codecs.open(os.path.join(outdir,
-                                               'pkglists',
-                                               '%s.rst' % label),
-                                  'w', 'utf-8')
-                toc.write(toc_template.render(
-                            label=label,
-                            title=underline_text(title_tmpl % id_, '='),
-                            pkgs=pkgsdict[id_],
-                            db=db))
-                toc.close()
-            except jinja2.exceptions.UndefinedError:
-                # ignore crap
-                pass
+            plist = toc_template.render(
+                        label=label,
+                        title=underline_text(title_tmpl % id_, '='),
+                        pkgs=filtered_pkgs,
+                        db=db)
+            toc = codecs.open(os.path.join(outdir,
+                                           'pkglists',
+                                           '%s.rst' % label),
+                              'w', 'utf-8')
+            toc.write(plist)
+            toc.close()
             hltoc.write('* :ref:`%s`\n' % label)
         hltoc.write('\n\n')
 
index 8e9799781c821dd89824cf68c8e8ebb743fe813e..26a89abdb7085d26a5a010218e9ef63fd95c8419 100644 (file)
@@ -8,7 +8,7 @@
   <li><a href="http://www.debian.org" target="_blank">Debian</a> ||&nbsp;</li>
   <li><a href="{{ pathto('index') }}">Neuroscience</a> :&nbsp;</li>
   <li><a href="{{ pathto('pkgs') }}">Software</a> |&nbsp;</li>
-  <li><a href="{{ pathto('datasets') }}">Datasets</a> |&nbsp;</li>
+  <li><a href="{{ pathto('pkglists/pkgs-by_release-datasets_(data)') }}">Datasets</a> |&nbsp;</li>
   <li><a href="{{ pathto('vm') }}">Virtual Machine</a> |&nbsp;</li>
   <li><a href="{{ pathto('faq') }}">FAQ</a> |&nbsp;</li>
   <li><a href="{{ pathto('testimonials') }}">Testimonials</a> &nbsp;</li>
index ef45b496b6f6cd76bf85c450547449c67d91dc77..495348e95e0ef71053be6129a9b31c43fac80aee 100644 (file)
@@ -27,7 +27,7 @@ you want to get involved. If you appreciate this service, please |spread|.
 
  <p>
  <a href="pkgs.html"><img border="0" src="_static/package.png" title="Software package list" /></a>
- <a href="pkglists/pkgs-by_purpose-neuroscience_datasets.html"><img border="0" src="_static/datasets.png" title="Dataset package list" /></a>
+ <a href="pkglists/pkgs-by_release-datasets_(data).html"><img border="0" src="_static/datasets.png" title="Dataset package list" /></a>
  <a href="vm.html"><img border="0" src="_static/machine.png" title="Get NeuroDebian for your non-Debian computer" /></a>
  <a href="debian/pool"><img border="0" src="_static/pool.png" title="Go to the package pool (deep and cold, only for experts)" /></a>
  <a href="projects.html"><img border="0" src="_static/workarea.png" title="Current and planned projects: Get involved!" /></a>