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

Ole Streicher olebole at debian.org
Sat Mar 5 16:08:06 UTC 2016


The following commit has been merged in the master branch:
commit a19e50bbd86cc3b004231180fc807db31190653b
Author: Ole Streicher <olebole at debian.org>
Date:   Sat Mar 5 17:07:09 2016 +0100

    Remove to_unicode from blendstasktool.py
    Conversion to unicode is not done centrally in RowDictionaries().

diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index 67a8feb..88319da 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -43,7 +43,6 @@ try:
     from debian import deb822
 except:
     from debian_bundle import deb822
-from blendsunicode import to_unicode
 from blendslanguages import languages
 
 import logging
@@ -304,7 +303,7 @@ def _execute_udd_query(query):
         curs.execute(query)
         logger.debug(query)
     except psycopg2.ProgrammingError, err:
-        print >>stderr, "Problem with query\n%s" % (to_unicode(query))
+        print >>stderr, "Problem with query\n%s" % query
         print >>stderr, err
         exit(-1)
     except psycopg2.DataError, err:
@@ -651,28 +650,18 @@ def FetchTasksFiles(data):
     return data['datadir'] + '/tasks'
 
 def RowDictionaries(cursor):
-    """Return a list of dictionaries which specify the values by their column names"""
+    """Return a list of dictionaries which specify the values by their
+    column names"""
 
-    description = cursor.description
-    if not description:
+    if not cursor.description:
         # even if there are no data sets to return the description should contain the table structure.  If not something went
-        # wrong and we return NULL as to represent a problem
+        # wrong and we return None as to represent a problem
         return NULL
-    if cursor.rowcount <= 0:
-        # if there are no rows in the cursor we return an empty list
-        return []
-
-    data = cursor.fetchall()
-    result = []
-
-    for row in data:
-        resultrow = {}
-        i = 0
-        for dd in description:
-            resultrow[dd[0]] = row[i]
-            i += 1
-        result.append(resultrow)
-    return result
+
+    return [ dict((dd[0],
+                   unicode(dv.decode('utf-8')) if isinstance(dv, str) else dv)
+                  for (dd, dv) in zip(cursor.description, row))
+             for row in cursor ]
 
 def BrowserFromVcsURL(vcs_type, vcs_url):
     # Guess Vcs-Browser URL from VCS URL
@@ -794,7 +783,7 @@ class DependantPackage:
             ret += ", desc: "         + str(self.desc)
         for prop in self.properties.keys():
             try:
-                ret += ", %s: %s" % (prop, to_unicode(str(self.properties[prop])))
+                ret += ", %s: %s" % (prop, str(self.properties[prop]))
             except UnicodeEncodeError:            
                 ret += ", %s: <UnicodeEncodeError>" % (prop)
         try:
@@ -850,22 +839,22 @@ class DependantPackage:
                         # emergency brake if algorithm fails to detect non-names like '1000 Genome Project Data Processing Subgroup'
                         if authors_string.count(',') > row[pub].count(' and '):
                             logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)", \
-                                            self.pkg, to_unicode(row[pub]), row[pub].count(' and '), to_unicode(authors_string), authors_string.count(','))
+                                            self.pkg, row[pub], row[pub].count(' and '), authors_string, authors_string.count(','))
                         else:
-                            logger.debug("Author string changed in %s: '%s' -> '%s'", self.pkg, to_unicode(row[pub]), to_unicode(authors_string))
+                            logger.debug("Author string changed in %s: '%s' -> '%s'", self.pkg, row[pub], authors_string)
                             row[pub] = authors_string
                 if not self.properties.has_key('published'):
                     self.properties['published'] = {}
                 if self.properties['published'].has_key(pub):
-                    if self.properties['published'][pub] == to_unicode(row[pub]):
+                    if self.properties['published'][pub] == row[pub]:
                     	try:
-                           print >>rmpub, "%s: %s: Published-%s: %s" % (self.taskname, self.pkg, pub, to_unicode(row[pub]))
+                           print >>rmpub, "%s: %s: Published-%s: %s" % (self.taskname, self.pkg, pub, row[pub])
             	        except UnicodeEncodeError:
             	           print >>rmpub, "--- %s: %s: Published-%s: some duplicated value featuring encoding problems ---" % (self.taskname, self.pkg, pub)
-            		logger.info("%s/%s: Publication-%s = %s can be removed"  % (self.taskname, self.pkg, pub, to_unicode(row[pub])))
+            		logger.info("%s/%s: Publication-%s = %s can be removed"  % (self.taskname, self.pkg, pub, row[pub]))
             	    else:
-            	        logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (self.pkg, pub, self.properties['published'][pub], to_unicode(row[pub])))
-                self.properties['published'][pub] = to_unicode(row[pub])
+            	        logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (self.pkg, pub, self.properties['published'][pub], row[pub]))
+                self.properties['published'][pub] = row[pub]
 
 class Tasks:
     # Provide a list of depencencies defined in metapackages
@@ -906,7 +895,7 @@ class Tasks:
         # sorted list of metapackage names
         self.metapackagekeys = []
         for task in os.listdir(self.tasksdir):
-            if os.path.isfile("%s/%s" % (self.tasksdir, task)):
+            if os.path.isfile(os.path.join(self.tasksdir, task)):
                 self.metapackagekeys.append(task)
         self.metapackagekeys.sort()
 
@@ -1196,7 +1185,7 @@ class TaskDependencies:
             if ddtptranslations['description_'+lang]:
                 self.metapkg.desc[lang] = {}
                 try:
-                    short = to_unicode(ddtptranslations['description_'+lang])
+                    short = ddtptranslations['description_'+lang]
                     self.metapkg.desc[lang]['short'] = MarkupString(short, self.metapkg.pkg, 'taskShortDesc', lang)
                 except UnicodeEncodeError, err:
                     logger.error("===> UnicodeDecodeError in metapackage %s (lang='%s'): '%s'; ErrTxt: %s" % \
@@ -1256,7 +1245,7 @@ class TaskDependencies:
             for key in stanza:
                 if key == 'Task':
                     # also the task name might be utf-8 encoded
-                    self.metapkg.PrintedName = to_unicode(stanza['task'])
+                    self.metapkg.PrintedName = stanza['task']
                     continue
                 if key == 'Description':
                     if found_description:
@@ -1292,8 +1281,6 @@ class TaskDependencies:
                         continue
                     if responsible != '':
                         (_name, _url) = email.Utils.parseaddr(responsible)
-                        _name = to_unicode(_name)
-			_url = to_unicode(_url)
                         try:
                             dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, _name)
 			    dep.responsible = dep.responsible.encode('utf-8')
@@ -1364,7 +1351,7 @@ class TaskDependencies:
                     if dep != None:
                         # set Homepage only if not just set via official package information
                         if dep.properties['homepage'] == HOMEPAGENONE:
-                            dep.properties['homepage'] = to_unicode(stanza['homepage'])
+                            dep.properties['homepage'] = stanza['homepage']
                         else:
                             fields_obsolete.append(key)
                     else:
@@ -1459,7 +1446,7 @@ class TaskDependencies:
                         if not dep.properties.has_key('published'):
                             dep.properties['published'] = {}
                         ptype = key.replace('Published-','').lower()
-                        dep.properties['published'][ptype] = to_unicode(stanza[key.lower()])
+                        dep.properties['published'][ptype] = stanza[key.lower()]
                     else:
                         logger.error("Dep not initiated before %s %s -> something is wrong." \
                               % (key, stanza[key.lower()]))
@@ -1492,7 +1479,7 @@ class TaskDependencies:
                     else:
                         # Only update use description from task file if not known from official package
                         if dep.desc['en'] == {}:
-                            (short, long) = SplitDescription(to_unicode(stanza['pkg-description']))
+                            (short, long) = SplitDescription(stanza['pkg-description'])
                             dep.desc['en']['short'] = short
                             dep.desc['en']['long']  = long
                         else:
@@ -1663,7 +1650,7 @@ class TaskDependencies:
 
                 if row['changed_by']:
                     try:
-                        changed = to_unicode(row['changed_by'])
+                        changed = row['changed_by']
                     except TypeError, err:
                         changed = None
                         logger.warning("Encoding problem for last uploader of package '%s' in task %s (%s)" % (dep.pkg, dep.taskname, err))
@@ -1672,8 +1659,8 @@ class TaskDependencies:
                             (_name, _url) = email.Utils.parseaddr(changed)
                             changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
                             dep.properties['changed_by']    = MarkupString(changed, dep.pkg, 'changed_by')
-                            dep.properties['last_uploader'] = to_unicode(changed)
-                            dep.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+                            dep.properties['last_uploader'] = changed
+                            dep.properties['last_uploader_simple'] = '%s <%s>' % (_name, _url)
                         except UnicodeDecodeError, err:
                             logger.error("Encoding problem for last uploader - assume same as maintainer for package %s (%s)", dep.pkg, err)
 
@@ -1684,15 +1671,15 @@ class TaskDependencies:
                 for l in languages:
                     if row['description_'+l]:
                         dep.desc[l] = {}
-                        dep.desc[l]['short'] = MarkupString(to_unicode(row['description_'+l]), dep.pkg, 'ShortDesc')
+                        dep.desc[l]['short'] = MarkupString(row['description_'+l], dep.pkg, 'ShortDesc')
                         if row['long_description_'+l]:
                             dep.desc[l]['long']  = Markup(render_longdesc(row['long_description_'+l].splitlines()))
                 if not dep.desc['en'].has_key('short'):
                     logger.error("Dep has no English short description: %s", dep.pkg)
                     dep.desc['en']['short'] = "??? missing short description for package %s :-(" % dep.pkg
                 (_name, _url) = email.Utils.parseaddr(row['maintainer'])
-                dep.properties['maintainer'] = to_unicode(row['maintainer'])
-                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name))
+                dep.properties['maintainer'] = row['maintainer']
+                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, _name)
 
                 if row['edam_topics']:
                     logger.info("Edam topics found for package %s: %s" % (dep.pkg, str(row['edam_topics'])))
@@ -1740,14 +1727,14 @@ class TaskDependencies:
                     logger.info("The package %s is not yet in Debian but it is just in the new queue. (Task %s)" % (dep.pkg, dep.taskname))
                 for prop in PROPERTIES:
                     dep.properties[prop] = row[prop]
-                dep.desc['en']['short'] = MarkupString(to_unicode(row['description_en']), dep.pkg, 'ShortDesc - New')
+                dep.desc['en']['short'] = MarkupString(row['description_en'], dep.pkg, 'ShortDesc - New')
                 dep.desc['en']['long']  = Markup(render_longdesc(row['long_description_en'].splitlines()))
                 (_name, _url) = email.Utils.parseaddr(row['maintainer'])
-                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name))
+                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, _name)
                 dep.SetPublications(row)
                 if row['changed_by']:
                     try:
-                        changed = to_unicode(row['changed_by'])
+                        changed = row['changed_by']
                     except TypeError, err:
                         changed = None
                         logger.warning("Encoding problem for uploader to ftpnew of package '%s' in task %s (%s)" % (dep.pkg, dep.taskname, err))
@@ -1756,8 +1743,8 @@ class TaskDependencies:
                             (_name, _url) = email.Utils.parseaddr(changed)
                             changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
                             dep.properties['changed_by']    = MarkupString(changed, dep.pkg, 'changed_by')
-                            dep.properties['last_uploader'] = to_unicode(changed)
-                            dep.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+                            dep.properties['last_uploader'] = changed
+                            dep.properties['last_uploader_simple'] = '%s <%s>' % (_name, _url)
                         except UnicodeDecodeError, err:
                             logger.error("Encoding problem for last uploader - assume same as maintainer for package %s (%s)", dep.pkg, err)
 
@@ -1826,13 +1813,13 @@ class TaskDependencies:
                 if int(row['wnpp']) > 0:
                     dep.properties['wnpp'] = row['wnpp']
                 dep.SetPublications(row)
-                dep.desc['en']['short'] = MarkupString(to_unicode(row['description_en']), dep.pkg, 'ShortDesc - New')
+                dep.desc['en']['short'] = MarkupString(row['description_en'], dep.pkg, 'ShortDesc - New')
                 dep.desc['en']['long']  = Markup(render_longdesc(row['long_description_en'].splitlines()))
                 (_name, _url) = email.Utils.parseaddr(row['maintainer'])
-                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name))
+                dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, _name)
                 if row['changed_by']:
                     try:
-                        changed = to_unicode(row['changed_by'])
+                        changed = row['changed_by']
                     except TypeError, err:
                         changed = None
                         logger.warning("Encoding problem for changelog author in Vcs of package '%s' in task %s (%s)" % (dep.pkg, dep.taskname, err))
@@ -1841,8 +1828,8 @@ class TaskDependencies:
                             (_name, _url) = email.Utils.parseaddr(changed)
                             changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
                             dep.properties['changed_by']    = MarkupString(changed, dep.pkg, 'changed_by')
-                            dep.properties['last_uploader'] = to_unicode(changed)
-                            dep.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+                            dep.properties['last_uploader'] = changed
+                            dep.properties['last_uploader_simple'] = '%s <%s>' % (_name, _url)
                         except UnicodeDecodeError, err:
                             logger.error("Encoding problem for changer - assume same as maintainer for package %s (%s)", dep.pkg, err)
 
@@ -2077,7 +2064,7 @@ class BugEntry:
 
     def __init__(self, bug):
         self.bug      = bug['id']
-	self.summary  = to_unicode(bug['title'])
+	self.summary  = bug['title']
 	self.severity = bug['severity']
 
         query = "EXECUTE bugs_query_tags (%i)" % self.bug

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list