[Blends-commit] r2407 - in /blends/trunk/webtools: blendstasktools.py blendsunicode.py templates/packagelist.xhtml

tille at users.alioth.debian.org tille at users.alioth.debian.org
Mon Oct 18 11:57:11 UTC 2010


Author: tille
Date: Mon Oct 18 11:57:07 2010
New Revision: 2407

URL: http://svn.debian.org/wsvn/blends/?sc=1&rev=2407
Log:
Add Versions available in Lenny and Squeeze to long listing

Modified:
    blends/trunk/webtools/blendstasktools.py
    blends/trunk/webtools/blendsunicode.py
    blends/trunk/webtools/templates/packagelist.xhtml

Modified: blends/trunk/webtools/blendstasktools.py
URL: http://svn.debian.org/wsvn/blends/blends/trunk/webtools/blendstasktools.py?rev=2407&op=diff
==============================================================================
--- blends/trunk/webtools/blendstasktools.py (original)
+++ blends/trunk/webtools/blendstasktools.py Mon Oct 18 11:57:07 2010
@@ -295,6 +295,13 @@
     ORDER BY releases.sort ASC, version DESC;"""
 curs.execute(query)
 
+query = """PREPARE pkg_versions_stable_testing (text) AS
+   SELECT release,  regexp_replace(regexp_replace(debversion, '-.*', ''), '[.+~]dfsg.*', '') AS version, debversion
+     FROM (SELECT r AS release, MAX(version) AS debversion
+             FROM versions_archs_component($1) AS (r text, version text, archs text, component text)
+            WHERE r IN ('lenny', 'squeeze') GROUP BY r) AS zw;"""  # Change here releases onace Squeeze is released
+curs.execute(query)
+
 # Obtain upstream version in case it is newer than Debian version
 query = """PREPARE pkg_dehs (text) AS
    SELECT DISTINCT d.source, unstable_upstream, unstable_parsed_version, unstable_status FROM dehs d
@@ -535,6 +542,7 @@
             self.properties[field]    = HOMEPAGENONE
         self.properties['Enhances'] = {} # Dictionary Enhancing pkg name as key, Link to package information as value; empty in most cases
                                          # because Enhances relations are quite seldom
+        self.properties['stable_testing_version'] = [] # (release, version) tuples where release is codename for stable and testing
         self.vcs_found      = 0    # we need a flag to store the fact whether Vcs information of a package is in UDD
         self.version        = []   # list of {'release', 'version', 'archs'} dictionary containing version and architecture information
         self.outdated       = {}   # If not empty directory then release='upstream' and package is outdated
@@ -625,6 +633,15 @@
                     self.version.append({'release':row['release'], 'version': row['version'], 'archs':row['archs']})
                 else:
                     self.version.append({'release':row['release'], 'version': row['version'] + ' (' + row['component'] + ')', 'archs':row['archs']})
+
+        # Version in stable / testing for long table
+        query = "EXECUTE pkg_versions_stable_testing ('%s')" % (self.pkg)
+        curs.execute(query)
+        if curs.rowcount > 0:
+            prefix = 'Versions: '
+            for row in RowDictionaries(curs):
+                self.properties['stable_testing_version'].append((row['release'], row['debversion'], row['version'], prefix))
+                prefix = ', '
 
         query = "EXECUTE pkg_dehs ('%s')" % (self.pkg)
         curs.execute(query)
@@ -734,12 +751,16 @@
             changed = None
             logger.info("Query '%s' does not result in a valid changed entry (%s)" % (query, err))
         if changed:
-            if not changed.startswith(self.properties['maintainer']):
-                (_name, _url) = email.Utils.parseaddr(changed)
-                changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
-                self.properties['changed_by']    = MarkupString(changed, self.pkg, 'changed_by')
-                self.properties['last_uploader'] = to_unicode(changed)
-                self.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+            # self.properties['maintainer'] = to_unicode(self.properties['maintainer']) # .encode('utf-8')
+            try:
+                if not changed.startswith(self.properties['maintainer']):
+                    (_name, _url) = email.Utils.parseaddr(changed)
+                    changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
+                    self.properties['changed_by']    = MarkupString(changed, self.pkg, 'changed_by')
+                    self.properties['last_uploader'] = to_unicode(changed)
+                    self.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+            except UnicodeDecodeError, err:
+                logger.error("Failed to compare changed with maintainer - assume both are the same for package %s (%s)", self.pkg, err)
 
         if source == 0: # If we are querying for source packages to render BTS pages
                 # tranlations are irrelevant - so only obtain ddtp translations

Modified: blends/trunk/webtools/blendsunicode.py
URL: http://svn.debian.org/wsvn/blends/blends/trunk/webtools/blendsunicode.py?rev=2407&op=diff
==============================================================================
--- blends/trunk/webtools/blendsunicode.py (original)
+++ blends/trunk/webtools/blendsunicode.py Mon Oct 18 11:57:07 2010
@@ -6,9 +6,18 @@
 # with different versions of python-debian
 #    python-debian <0.15 returns string; >=0.15 returns unicode
 
+from sys import stderr
+
 def to_unicode(value, encoding='utf-8'):
     if isinstance(value, str):
-        return value.decode(encoding)
+	try:
+    	    return value.decode(encoding)
+    	except UnicodeDecodeError, err:
+    	    print >>stderr, "type(value) =", type(value), \
+    	                    "; isinstance(value, str) =", isinstance(value, str), \
+    	                    ";", err
+    	    print >>stderr, value
+    	    return '???'
     else:
         return unicode(value)
 

Modified: blends/trunk/webtools/templates/packagelist.xhtml
URL: http://svn.debian.org/wsvn/blends/blends/trunk/webtools/templates/packagelist.xhtml?rev=2407&op=diff
==============================================================================
--- blends/trunk/webtools/templates/packagelist.xhtml (original)
+++ blends/trunk/webtools/templates/packagelist.xhtml Mon Oct 18 11:57:07 2010
@@ -58,6 +58,9 @@
 		    <span py:when="'#'">${project.pkg.capitalize()}</span>
 		    <span py:otherwise=""><a href="${project.properties['homepage']}">${project.pkg.capitalize()}</a></span>
 		  </span>
+                  <span py:choose="">
+		    <span py:when="len(project.properties['stable_testing_version'])>0">(<py:for each="version in project.properties['stable_testing_version']">${version[3]} <a href="http://packages.debian.org/${version[0]}/${project.pkg}">${version[2]}</a></py:for>)</span>
+                  </span>
 		  </dt>
 		  <dd><span py:choose="">
 		    <span py:when="project.desc.has_key(lang)">${project.desc[lang]['short']}</span>




More information about the Blends-commit mailing list