[Blends-commit] [SCM] website branch, master, updated. 807c891ab821de78b355216017348ac00548b5f1

Ole Streicher olebole at debian.org
Sun Mar 20 12:26:23 UTC 2016


The following commit has been merged in the master branch:
commit 807c891ab821de78b355216017348ac00548b5f1
Author: Ole Streicher <olebole at debian.org>
Date:   Sun Mar 20 13:26:12 2016 +0100

    Remove PackageByName entry in data

diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index 3b69ff3..0071727 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -1028,18 +1028,9 @@ class Tasks:
                                         break
                             logger.debug(" %s -> %s" % (enh, dep.properties['Enhances'][enh]))
 
-    @property
-    def PackageByName(self):
-        try:
-            return self._packageByName
-        except AttributeError:
-            deps = []
-            for task in self.tasks.values():
-                for d in task.dependencies.values():
-                    deps += d
-            self._packageByName = dict((dep.pkg, dep) for dep in deps)
-            return self._packageByName
-   
+    def getPackageCount(self):
+        return sum(task.getPackageCount() for task in self.tasks.values())
+
 class TaskDependencies:
     # List of depencencies defined in one metapackage
     def __init__(self, blendname, task, tasksdir=None):
@@ -1739,8 +1730,10 @@ class TaskDependencies:
             self.dependencies[dependency].sort()
         return 1  # Success
 
-    def _QueryUDD4Package(self, source):
+    def getPackageCount(self):
+        return sum(len(dep) for dep in self.dependencies.values())
 
+    def _QueryUDD4Package(self, source):
         query = "EXECUTE pkg_releases ('%s', '%s')" % (self.pkg, self.properties['component'])
         _execute_udd_query(query)
         has_official = 0
diff --git a/webtools/blendstasktools_udd.py b/webtools/blendstasktools_udd.py
index d396a6f..1b6a855 100644
--- a/webtools/blendstasktools_udd.py
+++ b/webtools/blendstasktools_udd.py
@@ -958,18 +958,9 @@ class Tasks:
                                         break
                             logger.debug(" %s -> %s" % (enh, dep.properties['Enhances'][enh]))
 
-    @property
-    def PackageByName(self):
-        try:
-            return self._packageByName
-        except AttributeError:
-            deps = []
-            for task in self.tasks.values():
-                for d in task.dependencies.values():
-                    deps += d
-            self._packageByName = dict((dep.pkg, dep) for dep in deps)
-            return self._packageByName
-   
+    def getPackageCount(self):
+        return sum(task.getPackageCount() for task in self.tasks.values())
+
 class TaskDependencies:
     # List of depencencies defined in one metapackage
     def __init__(self, blendname, task):
@@ -1293,6 +1284,9 @@ class TaskDependencies:
 
         return 1
 
+    def getPackageCount(self):
+        return sum(len(dep) for dep in self.dependencies.values())
+
     def __str__(self):
         ret = "Blend: " + self.blendname + ", " \
               "Task:"   + self.task      + ", " \
diff --git a/webtools/tasks.py b/webtools/tasks.py
index fb32b7e..8328f2d 100755
--- a/webtools/tasks.py
+++ b/webtools/tasks.py
@@ -33,8 +33,7 @@ data = tasks.data
 data['timestamp']        = formatdate(time.mktime(datetime.now().timetuple()))
 data['tasks']            = tasks.GetTaskDescDict()
 data['taskskeys']        = tasks.metapackagekeys
-data['PackageByName']    = tasks.PackageByName
-data['pkgcount']         = len(data['PackageByName'])
+data['pkgcount']         = tasks.getPackageCount()
 data['popconsubmit'] = tasks.popconsubmit or 'unknown'
 data['languages']    = languages
 
@@ -126,10 +125,10 @@ for lang in languages:
         data['projectadvertising'] = None
 
     data['packages']          = _('Packages')
-    data['idxsummary']        = _('''The {0} Pure Blend contains {1} packages which
+    data['idxsummary']        = _('''The {projectname} Pure Blend contains {pkgcount} packages which
         are grouped by metapackages. Each metapackage will cause the
         installation of packages for a specific topic. The following table lists
-        the metapackages of {0}''').format(data['projectname'], len(data['PackageByName']))
+        the metapackages of {projectname}''').format(**data)
 
     pkgstatus['official_high']['headline']    = _('Official Debian packages with high relevance')
     # before fiddling around with unicode() read
diff --git a/webtools/tasks_udd.py b/webtools/tasks_udd.py
index 7d78148..84bc572 100755
--- a/webtools/tasks_udd.py
+++ b/webtools/tasks_udd.py
@@ -33,8 +33,7 @@ data = tasks.data
 data['timestamp']        = formatdate(time.mktime(datetime.now().timetuple()))
 data['tasks']            = tasks.GetTaskDescDict()
 data['taskskeys']        = tasks.metapackagekeys
-data['PackageByName']    = tasks.PackageByName
-data['pkgcount']         = len(data['PackageByName'])
+data['pkgcount']         = tasks.getPackageCount()
 data['popconsubmit'] = tasks.popconsubmit or 'unknown'
 data['languages']    = languages
 
@@ -126,10 +125,10 @@ for lang in languages:
         data['projectadvertising'] = None
 
     data['packages']          = _('Packages')
-    data['idxsummary']        = _('''The {0} Pure Blend contains {1} packages which
+    data['idxsummary']        = _('''The {projectname} Pure Blend contains {pkgcount} packages which
         are grouped by metapackages. Each metapackage will cause the
         installation of packages for a specific topic. The following table lists
-        the metapackages of {0}''').format(data['projectname'], len(data['PackageByName']))
+        the metapackages of {projectname}''').format(**data)
 
     pkgstatus['official_high']['headline']    = _('Official Debian packages with high relevance')
     # before fiddling around with unicode() read
diff --git a/webtools/templates/debian-astro_idx.xhtml b/webtools/templates/debian-astro_idx.xhtml
index 7d9a404..869eea9 100644
--- a/webtools/templates/debian-astro_idx.xhtml
+++ b/webtools/templates/debian-astro_idx.xhtml
@@ -46,27 +46,43 @@
 	</p>
 
 	<h2>Featured packages</h2>
-	<py:for each="fp_row in [['stellarium', 'glueviz'], ['saods9', 'splash']]">
+	<py:for each="fp_row in [[('education', 'stellarium'),
+		                  ('python', 'glueviz')],
+		                 [('viewers', 'saods9'),
+				  ('simulation', 'splash')]]">
 	  <div class="line">
-	    <py:for each="pkg_name in fp_row">
+	    <py:for each="task_name, pkg_name in fp_row">
 	      <div class="col50">
+		<?python
+                   try:
+                       print task_name, pkg_name
+                       task = tasks[task_name]
+                       deps = []
+                       for d in task.dependencies.values():
+                          deps += d
+                       pkg = (dep for dep in deps if dep.pkg == pkg_name).next()
+                   except:
+                       pkg = None
+                ?>
 		<table>
 		  <tr>
 		    <td style="border-top-style: none; width:150px;">
-		      <img src="${PackageByName[pkg_name].properties['screenshot']['icon']}" alt="" style="width:150px;" />
+		      <img py:if="pkg is not None"
+			   src="${pkg.properties['screenshot']['icon']}"
+			   alt="" style="width:150px;" />
 		    </td>
 		    <td style="vertical-align:top; border-top-style: none;">
 		      <p style="margin-bottom:0;">
-			<strong>${PackageByName[pkg_name].pkg.capitalize()}:</strong>
+			<strong>${pkg_name.capitalize()}:</strong>
 			<span py:choose="">
-			  <span py:when="lang in PackageByName[pkg_name].desc">${PackageByName[pkg_name].desc[lang].get('short', '')}</span>
-			  <span py:otherwise="">${PackageByName[pkg_name].desc['en'].get('short', '')}</span>
+			  <span py:when="pkg is None"> </span>
+			  <span py:when="lang in pkg.desc">${pkg.desc[lang].get('short', '')}</span>
+			  <span py:otherwise="">${pkg.desc['en'].get('short', '')}</span>
 			</span>
-			
 		      </p>
 		      <p style="margin-bottom:0;">
-			<a href="${PackageByName[pkg_name].properties['homepage']}">Home page</a>
-			- <a href="tasks/${PackageByName[pkg_name].taskname}#${PackageByName[pkg_name].pkg}">More...</a>
+			<a py:if="pkg is not None" href="${pkg.properties['homepage']}">Home page</a>
+			- <a href="tasks/${task_name}#${pkg_name}">More...</a>
 		      </p>
 		    </td>
 		  </tr>

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list