]> git.donarmstrong.com Git - neurodebian.git/commitdiff
More robust package list generation.
authorMichael Hanke <michael.hanke@gmail.com>
Tue, 22 Mar 2011 16:01:07 +0000 (12:01 -0400)
committerMichael Hanke <michael.hanke@gmail.com>
Tue, 22 Mar 2011 16:01:07 +0000 (12:01 -0400)
neurodebian/dde.py

index 6bb59ca6daed21a9746aef484562108b1067c194..143c814ce7d87e2eceffa54d582389d9a2f8e1a3 100755 (executable)
@@ -6,6 +6,7 @@ import pysvn
 import json
 from debian_bundle import deb822
 import numpy as np
+import jinja2
 
 # Lets first assure no guarding (but annoying) warnings
 import warnings
@@ -768,16 +769,29 @@ def write_pkgpages(jinja_env, cfg, db, outdir, addenum_dir, extracts_dir):
         ids = pkgsdict.keys()
         for id_ in np.unique(ids):
             label = ('pkgs-%s-%s' % (sectitle, id_)).lower().replace(' ', '_').replace('/', '_')
-            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()
+            if not len(pkgsdict[id_]):
+                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
             hltoc.write('* :ref:`%s`\n' % label)
         hltoc.write('\n\n')