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

Ole Streicher olebole at debian.org
Tue Mar 8 10:00:49 UTC 2016


The following commit has been merged in the master branch:
commit dc962704ed0bc20801456f4142e22b01358e101c
Author: Ole Streicher <olebole at debian.org>
Date:   Tue Mar 8 09:33:46 2016 +0100

    More PEP-8 and Python-3 rewrite

diff --git a/webtools/blendsmarkdown.py b/webtools/blendsmarkdown.py
index 51692ca..6f10dbd 100644
--- a/webtools/blendsmarkdown.py
+++ b/webtools/blendsmarkdown.py
@@ -71,7 +71,8 @@ def render_longdesc(lines):
         try:
             LongDesc = publish_parts(MarkDownInput, writer_name='html')['body']
         except:
-            print >>stderr, "Unable to render the following prepared text:\n" + MarkDownInput
+            stderr.write("Unable to render the following prepared text:\n%s\n" %
+                         MarkDownInput)
             LongDesc = "Problems in rendering description using reST"
     else: # by default use Markdown
         LongDesc = markdown(MarkDownInput)
@@ -96,16 +97,16 @@ def MarkupString(string, pkg, elem, lang='en'):
     try:
         string = Markup(string)
     except UnicodeDecodeError, errtxt:
-        print >> stderr, "----> %s UnicodeDecodeError in %s (lang='%s'): '%s'; ErrTxt: %s" % \
-                                    (elem, pkg, lang, 'debug-string', errtxt)
+        stderr.write("----> %s UnicodeDecodeError in %s (lang='%s'): '%s'; ErrTxt: %s\n"
+                     % (elem, pkg, lang, 'debug-string', errtxt))
         try:
             string = Markup(unicode(string, 'utf-8'))
         except TypeError, errtxt:
-            print >> stderr, "====> %s TypeError in %s (lang='%s'): '%s'; ErrTxt: %s" % \
-                                    (elem, pkg, lang, 'debug-string', errtxt)
+            stderr.write("====> %s TypeError in %s (lang='%s'): '%s'; ErrTxt: %s\n"
+                         % (elem, pkg, lang, 'debug-string', errtxt))
     except TypeError, errtxt:
-        print >> stderr, "----> %s TypeError in %s (lang='%s'): '%s'; ErrTxt: %s" % \
-                                    (elem, pkg, lang, 'debug-string', errtxt)
+        stderr.write("----> %s TypeError in %s (lang='%s'): '%s'; ErrTxt: %s\n"
+                     % (elem, pkg, lang, 'debug-string', errtxt))
     return string
 
 rendering_lib  = ''
diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index dd9e111..8c37013 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -13,11 +13,6 @@
 # or if it is not contained it obtains information
 # from tasks file about home page, license, WNPP etc.
 
-#PORT=5441
-UDDPORT=5452
-PORT=UDDPORT
-DEFAULTPORT=5432
-
 from sys import stderr, exit
 from subprocess import Popen, PIPE
 import codecs
@@ -52,143 +47,151 @@ logger = logging.getLogger('blends')
 logger.setLevel(logging.INFO)
 # logger.setLevel(logging.DEBUG)
 
+# PORT = 5441
+UDDPORT = 5452
+PORT = UDDPORT
+DEFAULTPORT = 5432
+
 # Seems to have problems on 17.04.2009
 # BASEURL  = 'http://ftp.debian.org/debian'
-BASEURL  = 'http://ftp.de.debian.org/debian'
-KEYSTOIGNORE = ( 'Architecture', 'Comment', 'Leaf', 'NeedConfig', 'Note', 'Section',
-                 'Needconfig', 'DontAvoid',
-                 'Enhances', 'Test-always-lang', 'Metapackage')
+BASEURL = 'http://ftp.de.debian.org/debian'
+KEYSTOIGNORE = ('Architecture', 'Comment', 'Leaf', 'NeedConfig', 'Note', 'Section',
+                'Needconfig', 'DontAvoid',
+                'Enhances', 'Test-always-lang', 'Metapackage')
 
 CONFDIR = 'webconf'
 
-COMPRESSIONEXTENSION='bz2'
-# COMPRESSIONEXTENSION='gz' # Translations are only available as bz2 since April 2009
+COMPRESSIONEXTENSION = 'bz2'
+# COMPRESSIONEXTENSION = 'gz' # Translations are only available as bz2 since April 2009
 
 HOMEPAGENONE = '#'
-HOMEPAGENONEFIELDS = ('homepage', 
-                      'pkg-url',     # Link to packages.debian.org search interface with exact
-                                     # package matches or URL to inofficial package
-                      'vcs-browser', # Browser-URL to packaging stuff in Vcs
-                     )
+HOMEPAGENONEFIELDS = (
+    'homepage',
+    'pkg-url',      # Link to packages.debian.org search interface with exact
+                    # package matches or URL to inofficial package
+    'vcs-browser',  # Browser-URL to packaging stuff in Vcs
+)
 
 PKGURLMASK = 'http://packages.debian.org/search?keywords=%s%%26searchon=names%%26exact=1%%26suite=all%%26section=all'
 
 DEPENDENT  = 0
 SUGGESTED  = 1
 DONE       = 2
-BUGLISTCAT = (DEPENDENT, SUGGESTED, DONE )
+BUGLISTCAT = (DEPENDENT, SUGGESTED, DONE)
 
 # FIXME: Obtain releases from UDD table releases (is this used at all???)
-releases  = {'oldstable'    : ('wheezy', 'wheezy-proposed-updates', 'wheezy-security'),
-             'stable'       : ('jessie', 'jessie-proposed-updates', 'jessie-security'),
-             'testing'      : ('stretch'),
-             'unstable'     : ('sid'),
-             'experimental' : ('experimental')
-            }
-
-pkgstatus = {'official_high' : # official package with high priority dependency
-                               { 'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
-                                 'components'   : ('main', ),
-                                 'dependencies' : ('Depends', 'Recommends'),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'Green: The project is <a href="#%s">available as an official Debian package and has high relevance</a>',
-                                 'order'        : 1
-                               },
-             'official_low'  : # official package with low priority dependency
-                               { 'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
-                                 'components'   : ('main', ),
-                                 'dependencies' : ('Suggests', ),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'Green: The project is <a href="#%s">available as an official Debian package but has lower relevance</a>',
-                                 'order'        : 2
-                               },
-             'non-free'      : # package in contrib or non-free, priority decreased to Suggests in any case
-                               { 'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
-                                 'component'    : ('contrib', 'non-free'),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'Green: The project is <a href="#%s">available in Debian packaging pool but is not in Debian main</a>',
-                                 'order'        : 3
-                               },
-             'experimental'  : # package which exists only in experimental
-                               { 'releases'     : ('experimental', ),
-                                 'component'    : ('main', 'contrib', 'non-free'),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'Yellow: The project is <a href="#%s">available in Debian packaging pool but is regarded as experimental</a>',
-                                 'order'        : 4
-                               },
-             'new'           : # package in new queue
-                               { 'releases'     : ('new', ),
-                                 'component'    : ('main', 'contrib', 'non-free'),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'Yellow: A package of project is <a href="#%s">is in Debian New queue and hopefully available soon</a>',
-                                 'order'        : 5
-                               },
-             'pkgvcs'        : # Not yet packaged but packaging code in Vcs
-                               { 'releases'     : (),
-                                 'component'    : (),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : ('vcs-svn', 'vcs-git', 'vcs-browser'),
-                                 'colorcode'    : 'Yellow: The packaging of project is <a href="#%s">has started and a developer might try the packaging code in VCS or help packaging.</a>',
-                                 'order'        : 6
-                               },
-             'unofficial'    : # unofficial packages outside Debian
-                               { 'releases'     : (),
-                                 'component'    : (),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : ('pkg-url', ),
-                                 'colorcode'    : 'Yellow: There exists an <a href="#%s">unofficial package</a> of the project',
-                                 'order'        : 7
-                               },
-             'wnpp'          : # project which has at least a WNPP bug filed
-                               { 'releases'     : (),
-                                 'component'    : (),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : ('wnpp', ),
-                                 'colorcode'    : 'Red: The project is <a href="#%s">not (yet) available as a Debian package</a> but there is some record of interest (WNPP bug).',
-                                 'order'        : 8
-                               },
-             'prospective'   : # projects which might be interesting for a Blend but no work is done yet
-                               { 'releases'     : (),
-                                 'component'    : (),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : ('homepage', ),  # TODO: a description should be set as well ...
-                                 'colorcode'    : 'Red: The project is <a href="#%s">not (yet) available as a Debian package</a>.',
-                                 'order'        : 9
-                               },
-             'ignore'        : # Package inside Debian which is "under observation"
-                               { 'releases'     : (releases.keys()),
-                                 'component'    : ('main', 'contrib', 'non-free'),
-                                 'dependencies' : ('Ignore', ),
-                                 'fields-set'   : (),
-                                 'colorcode'    : '%s',
-                                 'order'        : 10
-                               },
-             'avoid'         : # Package inside Debian which should not go to a install medium of the Blend
-                               { 'releases'     : (releases.keys()),
-                                 'component'    : ('main', 'contrib', 'non-free'),
-                                 'dependencies' : ('Avoid', ),
-                                 'fields-set'   : (),
-                                 'colorcode'    : '%s',
-                                 'order'        : 11
-                               },
-             'unknown'       : # Everything else
-                               { 'releases'     : (),
-                                 'component'    : (),
-                                 'dependencies' : ('Depends', 'Recommends', 'Suggests'),
-                                 'fields-set'   : (),
-                                 'colorcode'    : 'White: The project has an %s status.',
-                                 'order'        : 100
-                               },
-             }
+releases = {
+    'oldstable'   : ('wheezy', 'wheezy-proposed-updates', 'wheezy-security'),
+    'stable'      : ('jessie', 'jessie-proposed-updates', 'jessie-security'),
+    'testing'     : ('stretch'),
+    'unstable'    : ('sid'),
+    'experimental': ('experimental')
+}
+
+pkgstatus = {
+    'official_high': {  # official package with high priority dependency
+        'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
+        'components'   : ('main', ),
+        'dependencies' : ('Depends', 'Recommends'),
+        'fields-set'   : (),
+        'colorcode'    : 'Green: The project is <a href="#%s">available as an official Debian package and has high relevance</a>',
+        'order'        : 1
+    },
+    'official_low' : {  # official package with low priority dependency
+        'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
+        'components'   : ('main', ),
+        'dependencies' : ('Suggests', ),
+        'fields-set'   : (),
+        'colorcode'    : 'Green: The project is <a href="#%s">available as an official Debian package but has lower relevance</a>',
+        'order'        : 2
+    },
+    'non-free'     : {  # package in contrib or non-free, priority decreased to Suggests in any case
+        'releases'     : ('oldstable', 'stable', 'testing', 'unstable'),
+        'component'    : ('contrib', 'non-free'),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : (),
+        'colorcode'    : 'Green: The project is <a href="#%s">available in Debian packaging pool but is not in Debian main</a>',
+        'order'        : 3
+    },
+    'experimental' : {  # package which exists only in experimental
+        'releases'     : ('experimental', ),
+        'component'    : ('main', 'contrib', 'non-free'),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : (),
+        'colorcode'    : 'Yellow: The project is <a href="#%s">available in Debian packaging pool but is regarded as experimental</a>',
+        'order'        : 4
+    },
+    'new'          : {  # package in new queue
+        'releases'     : ('new', ),
+        'component'    : ('main', 'contrib', 'non-free'),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : (),
+        'colorcode'    : 'Yellow: A package of project is <a href="#%s">is in Debian New queue and hopefully available soon</a>',
+        'order'        : 5
+    },
+    'pkgvcs'       : {  # Not yet packaged but packaging code in Vcs
+        'releases'     : (),
+        'component'    : (),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : ('vcs-svn', 'vcs-git', 'vcs-browser'),
+        'colorcode'    : 'Yellow: The packaging of project is <a href="#%s">has started and a developer might try the packaging code in VCS or help packaging.</a>',
+        'order'        : 6
+    },
+    'unofficial'   : {  # unofficial packages outside Debian
+        'releases'     : (),
+        'component'    : (),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : ('pkg-url', ),
+        'colorcode'    : 'Yellow: There exists an <a href="#%s">unofficial package</a> of the project',
+        'order'        : 7
+    },
+    'wnpp'         : {  # project which has at least a WNPP bug filed
+        'releases'     : (),
+        'component'    : (),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : ('wnpp', ),
+        'colorcode'    : 'Red: The project is <a href="#%s">not (yet) available as a Debian package</a> but there is some record of interest (WNPP bug).',
+        'order'        : 8
+    },
+    'prospective'  : {  # projects which might be interesting for a Blend but no work is done yet
+        'releases'     : (),
+        'component'    : (),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : ('homepage', ),  # TODO: a description should be set as well ...
+        'colorcode'    : 'Red: The project is <a href="#%s">not (yet) available as a Debian package</a>.',
+        'order'        : 9
+    },
+    'ignore'       : {  # Package inside Debian which is "under observation"
+        'releases'     : (releases.keys()),
+        'component'    : ('main', 'contrib', 'non-free'),
+        'dependencies' : ('Ignore', ),
+        'fields-set'   : (),
+        'colorcode'    : '%s',
+        'order'        : 10
+    },
+    'avoid'        : {  # Package inside Debian which should not go to a install medium of the Blend
+        'releases'     : (releases.keys()),
+        'component'    : ('main', 'contrib', 'non-free'),
+        'dependencies' : ('Avoid', ),
+        'fields-set'   : (),
+        'colorcode'    : '%s',
+        'order'        : 11
+    },
+    'unknown'      : {  # Everything else
+        'releases'     : (),
+        'component'    : (),
+        'dependencies' : ('Depends', 'Recommends', 'Suggests'),
+        'fields-set'   : (),
+        'colorcode'    : 'White: The project has an %s status.',
+        'order'        : 100
+    },
+}
 
 # http://wiki.python.org/moin/HowTo/Sorting#Sortingbykeys
-_tmplist=[]
+_tmplist = []
 for key in pkgstatus.keys():
-    _tmplist.append((key,pkgstatus[key]['order']))
-_tmpsorted = sorted(_tmplist, key=lambda x:(x[1], x[0]))
+    _tmplist.append((key, pkgstatus[key]['order']))
+_tmpsorted = sorted(_tmplist, key=lambda x: (x[1], x[0]))
 pkgstatus_sortedkeys = []
 for _tmp in _tmpsorted:
     pkgstatus_sortedkeys.append(_tmp[0])
@@ -199,45 +202,48 @@ for pkgstat in pkgstatus:
         if dep not in dep_strength_keys:
             dep_strength_keys.append(dep)
 
-rmpub = codecs.open('remove-publications-from-tasks-files.dat','w+', 'utf-8')
+rmpub = codecs.open('remove-publications-from-tasks-files.dat', 'w+', 'utf-8')
 
-license_in_component = {'main'     : 'DFSG free',
-                        'contrib'  : 'DFSG free, but needs non-free components',
-                        'non-free' : 'non-free'
-            }
+license_in_component = {
+    'main'    : 'DFSG free',
+    'contrib' : 'DFSG free, but needs non-free components',
+    'non-free': 'non-free'
+}
 
 try:
     import psutil
-    has_psutils=True
+    has_psutils = True
 except ImportError:
-    has_psutils=False
+    has_psutils = False
+
 
 def SetFilePermissions(usefile):
     try:
         blendsgid = grp.getgrnam("blends").gr_gid
         os.chown(usefile, -1, blendsgid)
-        os.chmod(usefile,  stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH )
+        os.chmod(usefile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
+                 stat.S_IWGRP | stat.S_IROTH)
         # os.system("ls -l %s" % usefile)
     except KeyError:
         # if groups 'blends' does not exist on the machine we are simply testing and setting group permissions is not needed
         pass
 
-LOCKFILE='/var/lock/blends.lock'
+
+LOCKFILE = '/var/lock/blends.lock'
 def LockBlendsTools():
     """Locking mechanism to make sure the scripts will not run in parallel
        which happened because of IO problems on udd.debian.org"""
     if not has_psutils:
-	logger.warning("Package python-psutil is missing.  No locking support available")
-	return
+        logger.warning("Package python-psutil is missing.  No locking support available")
+        return
     if os.path.exists(LOCKFILE):
         try:
-            lf = open(LOCKFILE, 'r')
-            pid = int(lf.readline())
-            lf.close()
-            try: # psutils has changed interfacde and get_pid_list() does not exist any more in newer implementations
-                pidlist=psutil.get_pid_list()
+            with open(LOCKFILE, 'r') as lf:
+                pid = int(lf.readline())
+            try:  # psutils has changed interfacde and get_pid_list() does not exist any more in newer implementations
+                pidlist = psutil.get_pid_list()
             except AttributeError:
-                pidlist=psutil.pids()
+                pidlist = psutil.pids()
             if pid in pidlist:
                 logger.error("Another process rebuilding web sentinel pages with PID %i is running. Exit." % pid)
                 exit()
@@ -246,19 +252,19 @@ def LockBlendsTools():
                 os.unlink(LOCKFILE)
         except IOError as e:
             pass
-    pid = os.getpid()
-    lf = open(LOCKFILE, 'w')
-    print >>lf, pid
-    lf.close()
+    with open(LOCKFILE, 'w') as lf:
+        lf.write('%i\n' % os.getpid())
     SetFilePermissions(LOCKFILE)
 
+
 def UnlockBlendsTools():
     """Unlock previousely locked file"""
     if os.path.exists(LOCKFILE):
         os.unlink(LOCKFILE)
 
+
 def GetDependencies2Use(dependencystatus=[], max_order='prospective'):
-    # Create a list of status of dependencies out of pkgstatus dictionary
+    #  Create a list of status of dependencies out of pkgstatus dictionary
     use_dependencystatus = []
     if dependencystatus == []:
         for pkgstat in pkgstatus_sortedkeys:
@@ -268,7 +274,7 @@ def GetDependencies2Use(dependencystatus=[], max_order='prospective'):
                 continue
             use_dependencystatus.append(pkgstat)
     else:
-        # verify correctly given dependencies
+        #  verify correctly given dependencies
         for pkgstat in dependencystatus:
             if pkgstat in pkgstatus.keys():
                 use_dependencystatus.append(pkgstat)
@@ -281,34 +287,38 @@ def GetDependencies2Use(dependencystatus=[], max_order='prospective'):
 ###########################################################################################
 # Define several prepared statements to query UDD
 try:
-  conn = psycopg2.connect(host="localhost",port=PORT,user="guest",database="udd")
+    conn = psycopg2.connect(host="localhost", port=PORT, user="guest",
+                            database="udd")
 except psycopg2.OperationalError, err:
-  try:
-    conn = psycopg2.connect("service=udd")
-  except psycopg2.OperationalError, err:
-    # logger not known at this state: logger.warning
-    print >>stderr, "Service=udd seems not to be installed on this host.\tMessage: %s" % (str(err))
     try:
-        conn = psycopg2.connect(host="localhost",port=DEFAULTPORT,user="guest",database="udd")
-    except psycopg2.OperationalError:
-	# Hmmm, I observed a really strange behaviour on one of my machines where connecting to
-	# localhost does not work but 127.0.0.1 works fine.  No idea why ... but this should
-	# do the trick for the moment
-	conn = psycopg2.connect(host="127.0.0.1",port=DEFAULTPORT,user="guest",database="udd")
+        conn = psycopg2.connect("service=udd")
+    except psycopg2.OperationalError, err:
+        # logger not known at this state: logger.warning
+        stderr.write("Service=udd seems not to be installed on this host.\tMessage: %s\n" % (str(err)))
+        try:
+            conn = psycopg2.connect(host="localhost", port=DEFAULTPORT,
+                                    user="guest", database="udd")
+        except psycopg2.OperationalError:
+            # Hmmm, I observed a really strange behaviour on one of my
+            # machines where connecting to localhost does not work but
+            # 127.0.0.1 works fine.  No idea why ... but this should
+            # do the trick for the moment
+            conn = psycopg2.connect(host="127.0.0.1", port=DEFAULTPORT,
+                                    user="guest", database="udd")
 
 curs = conn.cursor()
 # uddlog = open('logs/uddquery.log', 'w')
 
+
 def _execute_udd_query(query):
     try:
         curs.execute(query)
         logger.debug(query)
     except psycopg2.ProgrammingError, err:
-        print >>stderr, "Problem with query\n%s" % query
-        print >>stderr, err
+        stderr.write("Problem with query\n%s\n%s\n" % (query, str(err)))
         exit(-1)
     except psycopg2.DataError, err:
-        print >>stderr, "%s; query was\n%s" % (err, query)
+        stderr.write("%s; query was\n%s\n" % (str(err), query))
 
 query = """PREPARE query_pkgs (text[],text[],text) AS
         SELECT * FROM blends_query_packages($1,$2,$3) AS (
@@ -317,10 +327,10 @@ query = """PREPARE query_pkgs (text[],text[],text) AS
           source text, section text, task text, homepage text,
           maintainer_name text, maintainer_email text,
           "vcs-type" text, "vcs-url" text, "vcs-browser" text,
-	  changed_by text,
+          changed_by text,
           enhanced text[],
           releases text[], versions text[], architectures text[],
-	  unstable_upstream text, unstable_parsed_version text, unstable_status text,
+          unstable_upstream text, unstable_parsed_version text, unstable_status text,
           vote int, recent int, insts int, -- popcon
           debtags text[],
           screenshot_versions text[], image text[], icon text[],
@@ -382,7 +392,7 @@ query = """PREPARE query_new (text[]) AS SELECT
          bibpages.value   AS "pages",
          bibeprint.value  AS "eprint"
                    FROM new_packages p
-		   JOIN new_sources s ON p.source = s.source AND p.version = s.version
+                   JOIN new_sources s ON p.source = s.source AND p.version = s.version
     LEFT OUTER JOIN bibref bibyear    ON p.source = bibyear.source    AND bibyear.rank = 0    AND bibyear.key    = 'year'    AND bibyear.package = ''
     LEFT OUTER JOIN bibref bibtitle   ON p.source = bibtitle.source   AND bibtitle.rank = 0   AND bibtitle.key   = 'title'   AND bibtitle.package = ''
     LEFT OUTER JOIN bibref bibauthor  ON p.source = bibauthor.source  AND bibauthor.rank = 0  AND bibauthor.key  = 'author'  AND bibauthor.package = ''
@@ -394,7 +404,7 @@ query = """PREPARE query_new (text[]) AS SELECT
     LEFT OUTER JOIN bibref bibnumber  ON p.source = bibnumber.source  AND bibnumber.rank = 0  AND bibnumber.key  = 'number'  AND bibnumber.package = ''
     LEFT OUTER JOIN bibref bibpages   ON p.source = bibpages.source   AND bibpages.rank = 0   AND bibpages.key   = 'pages'   AND bibpages.package = ''
     LEFT OUTER JOIN bibref bibeprint  ON p.source = bibeprint.source  AND bibeprint.rank = 0  AND bibeprint.key  = 'eprint'  AND bibeprint.package = ''
-                   WHERE (p.package, p.version) IN  
+                   WHERE (p.package, p.version) IN
                          (SELECT package, max(version) FROM
                    new_packages WHERE package = ANY ($1) GROUP BY package)"""
 _execute_udd_query(query)
@@ -471,15 +481,15 @@ _execute_udd_query(query)
 # Sometimes the tasks file contains dependencies from virtual packages and we have to
 # obtain the real packages which provide this dependency.
 # First check whether there are such packages (only names)
-query = """PREPARE query_provides (text[]) AS 
+query = """PREPARE query_provides (text[]) AS
            SELECT DISTINCT package, provides FROM packages WHERE provides IS NOT NULL AND package = ANY($1) ;"""
 _execute_udd_query(query)
 
 # Obtain more detailed information about packages that might provide a dependency
-#query = """PREPARE query_provides_version_release (text) AS 
+# query = """PREPARE query_provides_version_release (text) AS
 #           SELECT package, version, release FROM packages WHERE provides = $1
 #                  GROUP BY version, package, release ORDER BY version DESC;"""
-#_execute_udd_query(query)
+# _execute_udd_query(query)
 
 # Obtain the releases featuring a certain package, in case a package might show up in different components when
 # considering different releases we apply a preference for main over contrib over non-free.  If this is the case
@@ -500,16 +510,19 @@ _execute_udd_query(query)
 
 #########################################################################################
 
+
 def List2PgArray(l):
     # turn a list of strings into the syntax for a PostgreSQL array:
     # {"string1","string2",...,"stringN"}
     return '{' + ','.join(('"' + s + '"') for s in l) + '}'
 
+
 def List2PgSimilarArray(l):
     # turn a list of strings surrounded by '%' into the syntax for a PostgreSQL array to enable LIKE conditions:
     # {"%string1%","%string2%",...,"%stringN%"}
     return '{' + ','.join(('"%' + s + '%"') for s in l) + '}'
 
+
 def ReadConfig(blendname=''):
     # Try to read config file CONFDIR/<blendname>.conf
     conffile = CONFDIR + '/' + blendname + '.conf'
@@ -517,26 +530,28 @@ def ReadConfig(blendname=''):
         # if config file can not be found in local dir, try /etc/blends/webconf as fallback
         conffile_default = '/etc/blends/webconf/' + blendname + '.conf'
         if not os.access(conffile_default, os.R_OK):
-            logger.error("Unable to open config file %s or %s." % (conffile, conffile_default))
+            logger.error("Unable to open config file %s or %s."
+                         % (conffile, conffile_default))
             exit(-1)
         conffile = conffile_default
     f = open(conffile, 'r')
-    ret = { 'Blend'       : '',
-            'projectname' : '',
-            'projecturl'  : '',
-            'homepage'    : '',
-            'aliothurl'   : '',
-            'projectlist' : '',
-            'pkglist'     : '',
-            'logourl'     : '',
-            'css'         : '',
-            'outputdir'   : '',
-            'datadir'     : '',
-            'advertising' : None,  # headline with advertising string is optional
-            'ubuntuhome'  : None,
-            'projectubuntu':None,
-          }
-    for stanza in deb822.Sources.iter_paragraphs(f, shared_storage=False):    
+    ret = {
+        'Blend'        : '',
+        'projectname'  : '',
+        'projecturl'   : '',
+        'homepage'     : '',
+        'aliothurl'    : '',
+        'projectlist'  : '',
+        'pkglist'      : '',
+        'logourl'      : '',
+        'css'          : '',
+        'outputdir'    : '',
+        'datadir'      : '',
+        'advertising'  : None,  # headline with advertising string is optional
+        'ubuntuhome'   : None,
+        'projectubuntu': None,
+    }
+    for stanza in deb822.Sources.iter_paragraphs(f, shared_storage=False):
         ret['Blend']       = stanza['blend']        # short name of the project
         ret['projectname'] = stanza['projectname']  # Printed name of the project
         ret['projecturl']  = stanza['projecturl']   # Link to the developer page with dynamic content
@@ -546,7 +561,7 @@ def ReadConfig(blendname=''):
         ret['aliothurl']   = stanza['aliothurl']    # Link to the Alioth page of the project
         ret['projectlist'] = stanza['projectlist']  # Mailinglist of the project
         if 'pkglist' in stanza:
-    	    ret['pkglist'] = stanza['pkglist']      # Packaging Mailinglist = Maintainer of group maintained packages
+            ret['pkglist'] = stanza['pkglist']      # Packaging Mailinglist = Maintainer of group maintained packages
         if 'logourl' in stanza:
             ret['logourl'] = stanza['logourl']      # URL to logo image (might be missing
         ret['css']         = stanza['css']          # (relative) URL to CSS file
@@ -567,6 +582,7 @@ def ReadConfig(blendname=''):
 
     return ret
 
+
 def CheckOrCreateOutputDir(maindir, subdir):
     outputdir = maindir + '/' + subdir
     if not os.access(outputdir, os.W_OK):
@@ -577,10 +593,11 @@ def CheckOrCreateOutputDir(maindir, subdir):
             try:
                 os.system("mkdir -p %s" % outputdir)
             except:
-                logger.error("Unable to create output dir " + outputdir)
+                logger.error("Unable to create output dir %s" % outputdir)
                 return None
     return outputdir
 
+
 def FetchTasksFiles(data):
     # Fetch tasks files from SVN of a Blend
     # The specification of the repository containing the tasks files
@@ -591,23 +608,23 @@ def FetchTasksFiles(data):
     # Checkout/Update tasks from SVN
     if data['vcsdir'].startswith('svn:'):
         for dir in ('tasks', 'debian'):
-            tasksdir = data['datadir'] + '/' + dir
+            tasksdir = os.path.join(data['datadir'], dir)
             if not os.access(tasksdir, os.W_OK):
                 try:
                     os.makedirs(tasksdir)
                 except:
                     logger.error("Unable to create data directory", tasksdir)
-    	    svncommand = "svn %%s %%s %s >> /dev/null" % ( tasksdir)
-    	    if os.path.isdir(tasksdir+'/.svn'):
-    	        svncommand = svncommand % (' --accept theirs-conflict up', '')
+            svncommand = "svn %%s %%s %s >> /dev/null" % tasksdir
+            if os.path.isdir(os.path.join(tasksdir, '.svn')):
+                svncommand = svncommand % (' --accept theirs-conflict up', '')
             else:
                 os.system("mkdir -p %s" % (tasksdir))
-                svncommand = svncommand % ('co', data['vcsdir']+'/'+dir)
+                svncommand = svncommand % ('co', os.path.join(data['vcsdir'], dir))
             if os.system(svncommand):
-    	        logger.error("SVN command %s failed" % (svncommand))
-    	        if os.path.isdir(tasksdir+'/.svn'):
-    		    logger.error("Trying old files in %s ..." % tasksdir)
-    	        else:
+                logger.error("SVN command %s failed" % svncommand)
+                if os.path.isdir(os.path.join(tasksdir, '.svn')):
+                    logger.error("Trying old files in %s ..." % tasksdir)
+                else:
                     if os.listdir(tasksdir):
                         logger.warning("No .svn directory found in %s but trying those random files there as tasks files." % tasksdir)
                     else:
@@ -617,24 +634,26 @@ def FetchTasksFiles(data):
         githtml = data['vcsdir']
 #        if githtml.startswith('git:'):
 #            githtml=githtml.replace('git://','http://')
-    	if os.path.isdir(data['datadir']+'/.git'):
-	    gitcommand = "cd %s; git pull --quiet" % data['datadir']
-	else:
-	    gitcommand = "git clone --quiet %s %s" % (githtml, data['datadir'])
+        if os.path.isdir(os.path.join(data['datadir'], '.git')):
+            gitcommand = "cd %s; git pull --quiet" % data['datadir']
+        else:
+            gitcommand = "git clone --quiet %s %s" % (githtml, data['datadir'])
         if os.system(gitcommand):
-    	    logger.error("Git command %s failed" % (gitcommand))
-    	    if os.path.isdir(data['datadir']+'/.git'):
+            logger.error("Git command %s failed" % (gitcommand))
+            if os.path.isdir(os.path.join(data['datadir'], '.git')):
                 logger.error("Trying old files in %s ..." % data['datadir'])
-    	    else:
+            else:
                 if os.listdir(data['datadir']):
                     logger.warning("No .git directory found in %s but trying those random files there as tasks files." % data['datadir'])
                 else:
                     logger.error("There are no old files in %s -> giving up" % data['datadir'])
                     exit(-1)
     else:
-        logger.error("Don't know how to checkout tasks files from %s -> giving up" % data['vcsdir'])
+        logger.error("Don't know how to checkout tasks files from %s -> giving up"
+                     % data['vcsdir'])
         exit(-1)
-    return data['datadir'] + '/tasks'
+    return os.path.join(data['datadir'], 'tasks')
+
 
 def RowDictionaries(cursor):
     """Return a list of dictionaries which specify the values by their
@@ -643,12 +662,13 @@ def RowDictionaries(cursor):
     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 None as to represent a problem
-        return NULL
+        return None
+
+    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]
 
-    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
@@ -683,6 +703,7 @@ detect_vcs_cvs_re        = re.compile("://.*cvs")
 detect_vcs_svn_re        = re.compile("://.*svn")
 detect_vcs_git_re        = re.compile("://.*git")
 
+
 def VcsTypeFromBrowserURL(vcs_browser):
     # Guess Vcs-Type from vcs_browser
     if detect_vcs_cvs_re.search(vcs_browser):
@@ -695,59 +716,60 @@ def VcsTypeFromBrowserURL(vcs_browser):
 
 # The following keys will be mostly used for programs that
 # are not yet existing in Debian and will go to our todo list
-PROPERTIES=('homepage', # Homepage of program
-            'section',  # Section of package in the Debian hierarchy
-            'source',   # Keep the source package name which is needed for ddpo subscription
-           )
+PROPERTIES = (
+    'homepage',  # Homepage of program
+    'section',   # Section of package in the Debian hierarchy
+    'source',    # Keep the source package name which is needed for ddpo subscription
+)
+
 
 class DependantPackage:
     # Hold information about a package that is in dependency list
 
     def __init__(self, blendname=None, taskname=None):
-        self.blendname      = blendname # Blend that includes the package in dependency list
-        self.taskname       = taskname  # Task which includes the Dependency
-        self.pkg            = None # Name of dependant package
-        self.source         = None # Name of source package of the dependency
-        self.PrintedName    = None # Only for Meta package names - no use for a real dependant package
-                                   # FIXME -> object model
-        self.pkgstatus      = 'unknown' # global pkgstatus: characterizes status of dependency, release, packaging status
-        self.releases       = []   # List of releases a package might be in
-        self.component      = None # One of: 'main', 'contrib', 'non-free', if a package shows up in several components which
-                                   # might happen over different releases, just prefer main over contrib over non-free
-        self.why            = None # basically used as comment
+        self.blendname      = blendname  # Blend that includes the package in dependency list
+        self.taskname       = taskname   # Task which includes the Dependency
+        self.pkg            = None  # Name of dependant package
+        self.source         = None  # Name of source package of the dependency
+        self.PrintedName    = None  # Only for Meta package names - no use for a real dependant package
+                                    # FIXME -> object model
+        self.pkgstatus      = 'unknown'  # global pkgstatus: characterizes status of dependency, release, packaging status
+        self.releases       = []    # List of releases a package might be in
+        self.component      = None  # One of: 'main', 'contrib', 'non-free', if a package shows up in several components which
+                                    # might happen over different releases, just prefer main over contrib over non-free
+        self.why            = None  # basically used as comment
 
         self.properties     = {}
         self.properties['license']     = 'unknown'
         for field in HOMEPAGENONEFIELDS:
             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
-        self.popcon         = {}   # dictionary containing vote and recnt values of popcon information
-        self.popconsubmit   = 0    # number of popcon submissions - in case popcon import into UDD might be broken this remains 0
-        self.debtags        = []   # list of {'tag', 'value'} dictionary containing debtag information
-        self.screenshots    = []   # list of {'version', 'url'} dictionary containing screenshot information
-        self.icon           = None # URL of small screenshot icon
-        self.screenshot_url = None # URL to screenshots.debian.net
-        self.responsible    = None # E-Mail address of issuer of ITP or some person
-                                   # who volunteered to care for this program
-        self.filename       = None # Filename of package in the Debian pool
-        self.desc           = {}   # Prospective packages should have a description ...
-                                   # ... which could be copied to (or from if exists)
-                                   # WNPP bug and finally can be used for packaging
-        self.desc['en']     = {}   # An English description should be available in any case
-        self.experimental   = 0    # Set to 1 if package *only* in experimental but not in unstable/testing/stable
-        self.remark         = {}   # Optional remark for a package
-        self.dep_strength   = 0    # Type of Dependency (Depends, Recommends, Suggests, Experimental, New, Avoid, Ignore, WNPP
-
+        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
+        self.popcon         = {}    # dictionary containing vote and recnt values of popcon information
+        self.popconsubmit   = 0     # number of popcon submissions - in case popcon import into UDD might be broken this remains 0
+        self.debtags        = []    # list of {'tag', 'value'} dictionary containing debtag information
+        self.screenshots    = []    # list of {'version', 'url'} dictionary containing screenshot information
+        self.icon           = None  # URL of small screenshot icon
+        self.screenshot_url = None  # URL to screenshots.debian.net
+        self.responsible    = None  # E-Mail address of issuer of ITP or some person
+                                    # who volunteered to care for this program
+        self.filename       = None  # Filename of package in the Debian pool
+        self.desc           = {}    # Prospective packages should have a description ...
+                                    # ... which could be copied to (or from if exists)
+                                    # WNPP bug and finally can be used for packaging
+        self.desc['en']     = {}    # An English description should be available in any case
+        self.experimental   = 0     # Set to 1 if package *only* in experimental but not in unstable/testing/stable
+        self.remark         = {}    # Optional remark for a package
+        self.dep_strength   = 0     # Type of Dependency (Depends, Recommends, Suggests, Experimental, New, Avoid, Ignore, WNPP
 
     # sort these objects according to the package name
     def __cmp__(self, other):
         # Comparing with None object has to return something reasonable
-        if other == None:
+        if other is None:
             return -2
         # Sort according to package name
         return cmp(self.pkg, other.pkg)
@@ -771,7 +793,8 @@ class DependantPackage:
         for prop in self.properties.keys():
             ret += ", %s: %s" % (prop, str(self.properties[prop]))
         try:
-            ret += ", popcon = %i (%i)" % (self.popcon['vote'], self.popcon['recent'])
+            ret += ", popcon = %i (%i)" % (self.popcon['vote'],
+                                           self.popcon['recent'])
         except:
             pass
         ret += ", debtags = " + str(self.debtags)
@@ -785,7 +808,8 @@ class DependantPackage:
         return ret
 
     def SetPublications(self, row):
-        for pub in ("year", "title", "authors", "doi", "pubmed", "url", "journal", "volume", "number", "pages", "eprint" ):
+        for pub in ("year", "title", "authors", "doi", "pubmed", "url",
+                    "journal", "volume", "number", "pages", "eprint"):
             if row[pub]:
                 if pub == "pages":
                     row[pub] = re.sub("--", "-", row[pub])
@@ -822,21 +846,23 @@ class DependantPackage:
                     if row[pub] != authors_string:
                         # 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, row[pub], row[pub].count(' and '), authors_string, authors_string.count(','))
+                            logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)"
+                                           % (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, row[pub], authors_string)
+                            logger.debug("Author string changed in %s: '%s' -> '%s'"
+                                         % (self.pkg, row[pub], authors_string))
                             row[pub] = authors_string
                 if 'published' not in self.properties:
                     self.properties['published'] = {}
                 if pub in self.properties['published']:
                     if self.properties['published'][pub] == row[pub]:
                         rmpub.write("%s: %s: Published-%s: %s" % (self.taskname, self.pkg, pub, 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], 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], row[pub]))
                 self.properties['published'][pub] = row[pub]
 
+
 class Tasks:
     # Provide a list of depencencies defined in metapackages
     # This class concerns _all_ tasks of a Blend and is the most
@@ -848,13 +874,14 @@ class Tasks:
     def __init__(self, blendname):
 
         os.system("mkdir -p logs")
-        LOG_FILENAME = 'logs/'+blendname+'.log'
-        handler = logging.handlers.RotatingFileHandler(filename=LOG_FILENAME,mode='w')
+        LOG_FILENAME = os.path.join('logs', blendname + '.log')
+        handler = logging.handlers.RotatingFileHandler(filename=LOG_FILENAME,
+                                                       mode='w')
         formatter = logging.Formatter("%(levelname)s - %(filename)s (%(lineno)d): %(message)s")
         handler.setFormatter(formatter)
         logger.addHandler(handler)
 
-	LockBlendsTools()
+        LockBlendsTools()
 
         # This Instance of the Available class contains all
         # information about packages that are avialable in Debian
@@ -863,14 +890,14 @@ class Tasks:
         self.blendname       = self.data['Blend']
         self.tasksdir        = FetchTasksFiles(self.data)
         self._InitMetapackages()
-        self.tasks           = {} # Dictionary of TasksDependency objects
-        self.alldeps_in_main = [] # sorted string list of package names with all packages
-                                  # relevant for a Blend that are in main Debian (for use in DDTP)
-        self.alldeps_in_main_info = {} # complete dictionary with package information
-                                  # with all packages relevant for a Blend that are in
-                                  # main to easily feed DDTP translation into the structures
-                                  # -->
-                                  # self.alldeps_in_main = self.alldeps_in_main_info.keys().sort()
+        self.tasks           = {}  # Dictionary of TasksDependency objects
+        self.alldeps_in_main = []  # sorted string list of package names with all packages
+                                   # relevant for a Blend that are in main Debian (for use in DDTP)
+        self.alldeps_in_main_info = {}  # complete dictionary with package information
+                                   # with all packages relevant for a Blend that are in
+                                   # main to easily feed DDTP translation into the structures
+                                   # -->
+                                   # self.alldeps_in_main = self.alldeps_in_main_info.keys().sort()
 
     def _InitMetapackages(self):
         # sorted list of metapackage names
@@ -928,7 +955,7 @@ class Tasks:
             td.SetMetapackageInfo(pkgname, translations)
             if td.GetTaskDependencies(source):
                 self.tasks[task] = td
-            else: # Kick file that is obviosely no task file from metapackage list
+            else:  # Kick file that is obviosely no task file from metapackage list
                 self.metapackagekeys = filter(lambda name: name != task, self.metapackagekeys)
 
         if source == 0:
@@ -947,7 +974,7 @@ class Tasks:
         # datastructure
         ret = {}
         use_dependencystatus = GetDependencies2Use(dependencystatus, 'experimental')
-             
+
         for task in self.metapackagekeys:
             tdeps = self.tasks[task]
             list = []
@@ -967,15 +994,15 @@ class Tasks:
             list = []
             for dep in use_dependencystatus:
                 for tdep in tdeps.dependencies[dep]:
-            	    if tdep.outdated != {}:
+                    if tdep.outdated != {}:
                         if 'last_uploader_simple' in tdep.properties:
                             last_uploader = tdep.properties['last_uploader_simple']
                         else:
                             last_uploader = None
-            		# versions are ordered lists      ---v--- last one is needed
-                	list.append(((tdep.pkg, tdep.version[-1]['version'], tdep.outdated['version'], tdep.properties['maintainer']), last_uploader))
+                        # versions are ordered lists      ---v--- last one is needed
+                        list.append(((tdep.pkg, tdep.version[-1]['version'], tdep.outdated['version'], tdep.properties['maintainer']), last_uploader))
             if list:
-        	ret[task] = list
+                ret[task] = list
         return ret
 
     def GetNamesAndSourceDict(self, dependencystatus=()):
@@ -983,12 +1010,13 @@ class Tasks:
         # source package as well to be able to link to the QA page
         # The lists are tripels with first value package name and the second source name
         # The last value characterises the strength of dependency: Possible values
-        # are 'suggested' for Suggested packages, and 
+        # are 'suggested' for Suggested packages, and
         ret = {}
         if dependencystatus == ():
             # see above in GetNamesOnlyDict() ... but when we are looking for bugs a
             # reasonable default is to use only official dependencystatus
-            dependencystatus=('official_high', 'official_low', 'non-free', 'experimental')
+            dependencystatus = ('official_high', 'official_low', 'non-free',
+                                'experimental')
 
         for task in self.metapackagekeys:
             tdeps = self.tasks[task]
@@ -1003,13 +1031,14 @@ class Tasks:
                     # packages outside main can not be Depends but only Suggests
                     if bugreldep == DEPENDENT and tdep.component != 'main':
                         bugreldep = SUGGESTED
-                    list.append( { 'pkgname'              : tdep.pkg,
-                                   'source'               : tdep.properties['source'],
-                                   'homepage'             : tdep.properties['homepage'],
-                                   'vcs-browser'          : tdep.properties['vcs-browser'],
-                                   'maintainer'           : tdep.responsible,
-                                   'bugrelevantdependency': bugreldep
-                                   } )
+                    list.append({
+                        'pkgname'              : tdep.pkg,
+                        'source'               : tdep.properties['source'],
+                        'homepage'             : tdep.properties['homepage'],
+                        'vcs-browser'          : tdep.properties['vcs-browser'],
+                        'maintainer'           : tdep.responsible,
+                        'bugrelevantdependency': bugreldep
+                    })
             ret[task] = list
         return ret
 
@@ -1065,10 +1094,10 @@ class Tasks:
                             for seek_dependency in tdeps.dependencies.keys():
                                 for enhdep in tdeps.dependencies[seek_dependency]:
                                     if enh == enhdep.pkg:
-                                        dep.properties['Enhances'][enh] = '#'+enh
-                                        found = 1 # found enhances in same task
+                                        dep.properties['Enhances'][enh] = '#' + enh
+                                        found = 1  # found enhances in same task
                                         break
-                            if found == 0: # If not found seek in other tasks
+                            if found == 0:  # If not found seek in other tasks
                                 for enhtask in self.metapackagekeys:
                                     if enhtask == task:
                                         continue
@@ -1077,7 +1106,7 @@ class Tasks:
                                         for enhdep in enhtdeps.dependencies[seek_dependency]:
                                             if enh == enhdep.pkg:
                                                 dep.properties['Enhances'][enh] = './' + enhtask + '#' + enh
-                                                found = 1 # found enhances in other task
+                                                found = 1  # found enhances in other task
                                                 break
                                     if found == 1:
                                         break
@@ -1113,23 +1142,23 @@ class Tasks:
                     komma = ', '
                 ret += ']'
             tab  = "\n       "
-        ret = ret + "\n" \
-              "All deps in main:" + str(self.alldeps_in_main) + ",\n" \
-              "All deps in main Info:" + str(self.alldeps_in_main_info)
+        ret += "\nAll deps in main:" + str(self.alldeps_in_main)
+        ret += ",\nAll deps in main Info:" + str(self.alldeps_in_main_info)
 
         return ret
 
+
 class TaskDependencies:
     # List of depencencies defined in one metapackage
     def __init__(self, blendname, task, tasksdir=None):
 
         self.data     = ReadConfig(blendname)
         self.blendname  = self.data['Blend']
-        if tasksdir != None:
+        if tasksdir is not None:
             self.tasksdir = tasksdir
         else:
             self.tasksdir = InitTasksFiles(self.data)
-        self.taskfile = self.tasksdir+'/'+task
+        self.taskfile = os.path.join(self.tasksdir, task)
         if os.path.isfile(self.taskfile):
             self.task = task
         else:
@@ -1153,7 +1182,6 @@ class TaskDependencies:
         # This is NOT YET implemented
         self.metadepends     = None
 
-
     def SetMetapackageInfo(self, pkgname, ddtptranslations=None):
         # Gather information (specifically description translations if exists) about metapackage itself
         self.metapkg             = DependantPackage(self.blendname, self.task)
@@ -1162,22 +1190,21 @@ class TaskDependencies:
         if not ddtptranslations:
             return
         for lang in languages:
-            if ddtptranslations['description_'+lang]:
+            if ddtptranslations['description_' + lang]:
                 self.metapkg.desc[lang] = {}
-                short = ddtptranslations['description_'+lang]
-                self.metapkg.desc[lang]['short'] = MarkupString(short, self.metapkg.pkg, 'taskShortDesc', lang)    
+                short = ddtptranslations['description_' + lang]
+                self.metapkg.desc[lang]['short'] = MarkupString(short, self.metapkg.pkg, 'taskShortDesc', lang)
                 try:
-                    self.metapkg.desc[lang]['long'] = Markup(render_longdesc(ddtptranslations['long_description_'+lang].splitlines()))
+                    self.metapkg.desc[lang]['long'] = Markup(render_longdesc(ddtptranslations['long_description_' + lang].splitlines()))
                 except AttributeError, err:
-                    logger.error("===> AttributeError in metapackage long %s (lang='%s'): '%s'; ErrTxt: %s" % \
-                                     (self.metapkg.pkg, lang, ddtptranslations['long_description_'+lang], err))
+                    logger.error("===> AttributeError in metapackage long %s (lang='%s'): '%s'; ErrTxt: %s"
+                                 % (self.metapkg.pkg, lang, ddtptranslations['long_description_' + lang], err))
                     self.metapkg.desc[lang]['long'] = 'Missing long description'
 
-
     def _AppendDependency2List(self, dep, source):
         # Append dependency which was found in the tasks file if not Ignore / Avoid and
         # no dupplication in case of source depencencies
-        if dep == None:
+        if dep is None:
             return
         if dep.dep_strength == 'Ignore' or dep.dep_strength == 'Avoid':
             return
@@ -1199,7 +1226,7 @@ class TaskDependencies:
     def GetTaskDependencies(self, source=0):
         global dep_strength_keys
 
-        found_description=False
+        found_description = False
         f = codecs.open(self.taskfile, "r", "utf-8")
         for stanza in deb822.Sources.iter_paragraphs(f):
             # Why and Responsible can be valid for more than one dependency
@@ -1223,7 +1250,7 @@ class TaskDependencies:
                         (short, long) = SplitDescription(stanza['description'])
                         # Markup strings to enable verbatim output of preformatted text
                         self.metapkg.desc['en']['short'] = MarkupString(short, self.metapkg.PrintedName, 'taskShortDesc')
-                        self.metapkg.desc['en']['long']  = MarkupString(long,  self.metapkg.PrintedName, 'taskLongDesc')
+                        self.metapkg.desc['en']['long']  = MarkupString(long, self.metapkg.PrintedName, 'taskLongDesc')
                         found_description = True
                     continue
                 if key == 'Meta-Depends':
@@ -1237,11 +1264,11 @@ class TaskDependencies:
                     continue
                 if key == 'Responsible':
                     responsible = stanza['responsible'].strip()
-            	    if not dep:
-            		# Make sure there is really enough information to deal with provided by the package
-            		logger.error("Missing package information for field %s = %s in task file %s" % (key, responsible, self.task))
-            		continue
-                    if dep.responsible != None:
+                    if not dep:
+                        # Make sure there is really enough information to deal with provided by the package
+                        logger.error("Missing package information for field %s = %s in task file %s" % (key, responsible, self.task))
+                        continue
+                    if dep.responsible is not None:
                         # we are dealing with an official package that has a real maintainer who
                         # is finally responsible
                         # ... but do not issue a hint about this in the logs. Sometimes a responsible
@@ -1264,19 +1291,19 @@ class TaskDependencies:
 
                     # turn alternatives ('|') into real depends for this purpose
                     # because we are finally interested in all alternatives
-                    dependencylist = dependencies.replace('|',',').split(',')
+                    dependencylist = dependencies.replace('|', ',').split(',')
                     # Collect all dependencies in one line first,
                     # create an object for each later
                     deps_in_one_line = []
                     for dependency in dependencylist:
-                        if dependency.strip() != '': # avoid confusion when ',' is at end of line
+                        if dependency.strip() != '':  # avoid confusion when ',' is at end of line
                             deps_in_one_line.append(dependency.strip())
 
                     for dep_in_line in deps_in_one_line:
                         # If there are more than one dependencies in one line
                         # just put the current one into the right list of dependencies
                         # before initiating the next instance
-                        if dep != None:
+                        if dep is not None:
                             tmp_dep_list.append(dep)
                         dep = DependantPackage(self.blendname, self.task)
                         # Store the comments in case they might be usefull for later applications
@@ -1287,15 +1314,15 @@ class TaskDependencies:
                             dep.pkg            = dep_in_line
                         else:
                             dep.pkg            = dep_in_line.lower()
-                            logger.warning("Package names may not contain upper case letters, so %s is an invalid package name which is turned into %s" \
-                                % (dep_in_line, dep.pkg))
+                            logger.warning("Package names may not contain upper case letters, so %s is an invalid package name which is turned into %s"
+                                           % (dep_in_line, dep.pkg))
 
                     continue
 
                 # sometimes the tasks file contains standalone comments or other RFC 822 entries.
                 # Just ignore this stuff
-                if dep == None:
-                    continue # ... with next stanza
+                if dep is None:
+                    continue  # ... with next stanza
 
                 # the following fields might be provided in the Blends tasks file for
                 # prospective packages.  This information should be ignored in case the
@@ -1311,20 +1338,20 @@ class TaskDependencies:
                 # The following keys will be mostly used for programs that
                 # are not yet existing in Debian and will go to our todo list
                 if key == 'Homepage':
-                    if fields_duplicated != None:
+                    if fields_duplicated is not None:
                         fields_duplicated.append(key)
-                    if dep != None:
+                    if dep is not None:
                         # set Homepage only if not just set via official package information
                         if dep.properties['homepage'] == HOMEPAGENONE:
                             dep.properties['homepage'] = stanza['homepage']
                         else:
                             fields_obsolete.append(key)
                     else:
-                        logger.error("Dep not initiated before Homepage %s -> something is wrong." \
-                              % stanza['homepage'])
-                elif key == 'Vcs-Svn' or key == 'vcs-svn': # strangely enough on alioth the later
-                                                           # spelling seems to be needed - no idea why
-                    if dep != None:
+                        logger.error("Dep not initiated before Homepage %s -> something is wrong."
+                                     % stanza['homepage'])
+                elif key == 'Vcs-Svn' or key == 'vcs-svn':  # strangely enough on alioth the later
+                                                            # spelling seems to be needed - no idea why
+                    if dep is not None:
                         if dep.vcs_found == 1:
                             fields_obsolete.append(key)
                             continue
@@ -1337,13 +1364,13 @@ class TaskDependencies:
                             except KeyError, err:
                                 logger.error("Vcs Property missing in packages file:", dep.properties, err)
                     else:
-                        logger.error("Dep not initiated before Vcs-Svn %s -> something is wrong." \
-                              % stanza['vcs-svn'])
+                        logger.error("Dep not initiated before Vcs-Svn %s -> something is wrong."
+                                     % stanza['vcs-svn'])
                     if dep.pkgstatus == 'unknown':
                         dep.pkgstatus = 'pkgvcs'
-                elif key == 'Vcs-Git' or key == 'vcs-git': # strangely enough on alioth the later
-                                                           # spelling seems to be needed - no idea why
-                    if dep != None:
+                elif key == 'Vcs-Git' or key == 'vcs-git':  # strangely enough on alioth the later
+                                                            # spelling seems to be needed - no idea why
+                    if dep is not None:
                         if dep.vcs_found == 1:
                             fields_obsolete.append(key)
                             continue
@@ -1353,94 +1380,94 @@ class TaskDependencies:
                         if dep.properties['vcs-browser'] == HOMEPAGENONE:
                             dep.properties['vcs-browser'] = BrowserFromVcsURL(dep.properties['vcs-type'], dep.properties['vcs-url'])
                     else:
-                        logger.error("Dep not initiated before Vcs-Git %s -> something is wrong." \
-                              % stanza['vcs-git'])
-                elif key == 'Vcs-Browser' or key == 'vcs-browser': # strangely enough on alioth the later
-                                                           # spelling seems to be needed - no idea why
-                    if dep != None:
+                        logger.error("Dep not initiated before Vcs-Git %s -> something is wrong."
+                                     % stanza['vcs-git'])
+                elif key == 'Vcs-Browser' or key == 'vcs-browser':  # strangely enough on alioth the later
+                                                                    # spelling seems to be needed - no idea why
+                    if dep is not None:
                         if dep.vcs_found == 1:
                             fields_obsolete.append(key)
                             continue
                         dep.properties['vcs-browser'] = stanza['vcs-browser']
                         if re.compile("[/.]git\.").search(dep.properties['vcs-browser']):
-                    	    dep.properties['vcs-type'] = 'Git'
+                            dep.properties['vcs-type'] = 'Git'
                         elif re.compile("[/.]svn\.").search(dep.properties['vcs-browser']):
-                    	    dep.properties['vcs-type'] = 'SVN'
-			else:
-			    # no chance to guess Vcs type
-                    	    dep.properties['vcs-type'] = 'Vcs'
+                            dep.properties['vcs-type'] = 'SVN'
+                        else:
+                            # no chance to guess Vcs type
+                            dep.properties['vcs-type'] = 'Vcs'
                         # There is no need to specify the Vcs-{Git,SVN} field in the tasks file but property 'vcs-type' should be set in
                         # any case - so set it here in case it was not set before.  If an apropriate field is set later it becomes
                         # overriden anyway
                         if 'vcs-url' not in dep.properties:
                             dep.properties['vcs-url'] = dep.properties['vcs-browser']
                     else:
-                        logger.error("Dep not initiated before Vcs-Browser %s -> something is wrong." \
-                              % stanza['vcs-browser'])
+                        logger.error("Dep not initiated before Vcs-Browser %s -> something is wrong."
+                                     % stanza['vcs-browser'])
                     if dep.pkgstatus == 'unknown':
                         dep.pkgstatus = 'pkgvcs'
                 elif key == 'section':
-                    if dep != None:
+                    if dep is not None:
                         dep.properties[key.lower()]  = stanza[key.lower()]
                     else:
-                        logger.error("Dep not initiated before %s %s -> something is wrong." \
-                              % (key, stanza[key.lower()]))
+                        logger.error("Dep not initiated before %s %s -> something is wrong."
+                                     % (key, stanza[key.lower()]))
                 elif key == 'License':
-                    if dep != None:
+                    if dep is not None:
                         if dep.vcs_found == 1 and key.lower() in dep.properties:
                             fields_obsolete.append(key)
                             continue
                         dep.properties[key.lower()]  = stanza[key.lower()]
                     else:
-                        logger.error("Dep not initiated before %s %s -> something is wrong." \
-                              % (key, stanza[key.lower()]))
+                        logger.error("Dep not initiated before %s %s -> something is wrong."
+                                     % (key, stanza[key.lower()]))
                 elif key == 'Language':
-                    if dep != None:
+                    if dep is not None:
                         dep.properties[key.lower()]  = stanza[key.lower()]
                     else:
-                        logger.error("Dep not initiated before %s %s -> something is wrong." \
-                              % (key, stanza[key.lower()]))
+                        logger.error("Dep not initiated before %s %s -> something is wrong."
+                                     % (key, stanza[key.lower()]))
                 elif key == 'Registration':
-                    if dep != None:
+                    if dep is not None:
                         dep.properties[key.lower()]  = stanza[key.lower()]
                     else:
-                        logger.error("Dep not initiated before %s %s -> something is wrong." \
-                              % (key, stanza[key.lower()]))
+                        logger.error("Dep not initiated before %s %s -> something is wrong."
+                                     % (key, stanza[key.lower()]))
                 elif key.startswith('Published-'):
-                    if dep != None:
+                    if dep is not None:
                         if 'published' not in dep.properties:
                             dep.properties['published'] = {}
-                        ptype = key.replace('Published-','').lower()
+                        ptype = key.replace('Published-', '').lower()
                         dep.properties['published'][ptype] = stanza[key.lower()]
                     else:
-                        logger.error("Dep not initiated before %s %s -> something is wrong." \
-                              % (key, stanza[key.lower()]))
+                        logger.error("Dep not initiated before %s %s -> something is wrong."
+                                     % (key, stanza[key.lower()]))
                 elif key == 'WNPP':
-                    if dep != None:
+                    if dep is not None:
                         if dep.vcs_found == 1 and key.lower() in dep.properties:
                             fields_obsolete.append(key)
                             continue
                         wnpp = stanza['wnpp'].strip()
                         # in case somebody prepended a '#' sign before the bug number
                         wnpp = re.sub('^#', '', wnpp)
-                    	# if there is really a number given
+                        # if there is really a number given
                         if re.compile("^\d+$").search(wnpp):
                             dep.properties['wnpp'] = wnpp
                     else:
-                        logger.error("Dep not initiated before WNPP %s -> something is wrong." \
-                              % stanza['wnpp'])
+                        logger.error("Dep not initiated before WNPP %s -> something is wrong."
+                                     % stanza['wnpp'])
                 elif key.lower() == 'pkg-url':
-                    if dep != None:
-                        if dep.properties['pkg-url'] == HOMEPAGENONE: # only if no official package is just available
+                    if dep is not None:
+                        if dep.properties['pkg-url'] == HOMEPAGENONE:  # only if no official package is just available
                             # Escape '&' in URLs with %26 (Trick stolen by pasting the URL into a search engine ;-))
                             dep.properties['pkg-url'] = stanza['pkg-url'].replace("&", "%26")
                     else:
-                        logger.error("Dep not initiated before Pkg-URL %s -> something is wrong." \
-                              % stanza['pkg-url'])
+                        logger.error("Dep not initiated before Pkg-URL %s -> something is wrong."
+                                     % stanza['pkg-url'])
                 elif key == 'Pkg-Description':
-                    if dep == None:
-                        logger.error("Dep not initiated before Pkg-Description %s -> something is wrong." \
-                              % stanza['pkg-description'].splitlines()[0])
+                    if dep is None:
+                        logger.error("Dep not initiated before Pkg-Description %s -> something is wrong."
+                                     % stanza['pkg-description'].splitlines()[0])
                     else:
                         # Only update use description from task file if not known from official package
                         if dep.desc['en'] == {}:
@@ -1454,15 +1481,15 @@ class TaskDependencies:
                     dep.pkgstatus = key.lower()
                 elif key == 'Remark':
                     (short, long) = SplitDescription(stanza['remark'])
-                    if dep == None:
+                    if dep is None:
                         _pkg = self.metapkg.PrintedName
                     else:
                         _pkg = dep.pkg
                     remark['short'] = MarkupString(short, _pkg, 'RemarkShort')
-                    remark['long']  = MarkupString(long,  _pkg, 'RemarkLong')
+                    remark['long']  = MarkupString(long, _pkg, 'RemarkLong')
                     continue
                 else:
-            	    if key not in KEYSTOIGNORE:
+                    if key not in KEYSTOIGNORE:
                         # Also ignore keys starting with X[A-Z]-
                         if not re.compile("^X[A-Z]*-").search(key):
                             try:
@@ -1470,8 +1497,8 @@ class TaskDependencies:
                             except:
                                 logger.error("Unknown key '%s' with problematic value in file %s." % (key, self.metapkg.PrintedName))
 
-            if dep == None:
-                continue # ... with next stanza
+            if dep is None:
+                continue  # ... with next stanza
             # seek for certain field set in the tasks file to move the dependency into different
             # categories of development status of not yet included packages provided that there
             # is at least a package description given
@@ -1495,23 +1522,23 @@ class TaskDependencies:
                 if remark != {}:
                     dep.remark = remark
                 if fields_obsolete != [] and dep.pkgstatus != 'new':
-                    logger.info("Package %s is an official package and has information in UDD. The following extra information can be removed from tasks file %s: %s" % \
-                                     (dep.pkg, dep.taskname, str(fields_obsolete)))
+                    logger.info("Package %s is an official package and has information in UDD. The following extra information can be removed from tasks file %s: %s"
+                                % (dep.pkg, dep.taskname, str(fields_obsolete)))
                 self._AppendDependency2List(dep, source)
 
         f.close()
 
-        alldepends=[]
+        alldepends = []
         for status in self.dependencies.keys():
             for dep in self.dependencies[status]:
                 alldepends.append(dep.pkg)
 
         if not self.metapkg.PrintedName:
             logger.error("Task file %s is lacking field 'Task' - and thus will be ignored" % self.taskfile)
-            return 0 # Failure
+            return 0  # Failure
         if not alldepends:
             logger.warning("No dependencies defined in taskfile %s" % self.task)
-            return 0 # Failure
+            return 0  # Failure
         query = "EXECUTE query_pkgs ('%s', '%s', '%s')" % (List2PgArray(alldepends), List2PgSimilarArray(alldepends), self.task)
         _execute_udd_query(query)
         pkgs_in_pool = []
@@ -1554,9 +1581,10 @@ class TaskDependencies:
                     self.dependencies[dep.pkgstatus].append(dep)
 
                 # Warn about remaining information of prospective package
-                if ( dep.desc['en'] and dep.desc['en']['short'] ) and \
-                    not dep.debtags: # prevent informing about packages which are just duplicated because of a broken query
-                    logger.info("WNPP for package %s just closed - extra information can be removed from task file %s." % (dep.pkg, dep.taskname))
+                if dep.desc['en'] and dep.desc['en']['short'] and not dep.debtags:
+                    # prevent informing about packages which are just duplicated because of a broken query
+                    logger.info("WNPP for package %s just closed - extra information can be removed from task file %s."
+                                % (dep.pkg, dep.taskname))
 
                 dep.properties['license'] = license_in_component[dep.component]
                 for prop in PROPERTIES:
@@ -1575,7 +1603,11 @@ class TaskDependencies:
                         enhancing_pkgs.append(pkg)
 
                 for i in range(len(row['releases'])):
-                    dep.version.append({'release':row['releases'][i], 'version': row['versions'][i], 'archs':row['architectures'][i]})
+                    dep.version.append({
+                        'release': row['releases'][i],
+                        'version': row['versions'][i],
+                        'archs': row['architectures'][i]
+                    })
 
                 dep.popcon['vote']   = row['vote']
                 dep.popcon['recent'] = row['recent']
@@ -1583,12 +1615,12 @@ class TaskDependencies:
 
                 # Debtags as sorted list of dict fields
                 if row['debtags']:
-                    if dep.debtags: # there is no reasonable way that debtags was set before - so something is wrong here and a warning should be issued
+                    if dep.debtags:  # there is no reasonable way that debtags was set before - so something is wrong here and a warning should be issued
                         logger.warning("Debtags for package '%s' was just set.  A duplicated result from database query is suspected.  Please check the result!" % dep.pkg)
                     tagdict = {}
                     taglist = []
                     for debtag in row['debtags']:
-                        (tag,value) = debtag.split('::')
+                        (tag, value) = debtag.split('::')
                         if tag in tagdict:
                             tagdict[tag] += ', ' + value
                         else:
@@ -1597,15 +1629,18 @@ class TaskDependencies:
                         if taglist:
                             taglist.sort()
                     for tag in taglist:
-                        dep.debtags.append({'tag':tag, 'value':tagdict[tag]})
+                        dep.debtags.append({'tag': tag, 'value': tagdict[tag]})
 
                 # screenshots
                 if row['icon']:
                     dep.icon           = row['icon'][0]
                     dep.image          = row['image'][0]
                     dep.screenshot_url = 'http://screenshots.debian.net/package/' + dep.pkg
-                    for i in range(1,len(row['image'])):
-                        dep.screenshots.append({'version':row['screenshot_versions'][i], 'url':row['image'][i]})
+                    for i in range(1, len(row['image'])):
+                        dep.screenshots.append({
+                            'version': row['screenshot_versions'][i],
+                            'url': row['image'][i]
+                        })
 
                 # it might be that the new upstream goes to experimental - this should be ignored here
                 if row['unstable_parsed_version']:
@@ -1631,11 +1666,12 @@ class TaskDependencies:
                 dep.properties['pkg-url'] = PKGURLMASK % dep.pkg
                 dep.SetPublications(row)
                 for l in languages:
-                    if row['description_'+l]:
+                    if row['description_' + l]:
                         dep.desc[l] = {}
-                        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()))
+                        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 'short' not in dep.desc['en']:
                     logger.error("Dep has no English short description: %s", dep.pkg)
                     dep.desc['en']['short'] = "??? missing short description for package %s :-(" % dep.pkg
@@ -1682,10 +1718,10 @@ class TaskDependencies:
                     self.dependencies['new'].append(dep)
                 dep.pkgstatus = 'new'
                 dep.component = row['component']
-                dep.version   = [ row['version'], ]
+                dep.version   = [row['version']]
                 dep.properties['pkg-url'] = 'http://ftp-master.debian.org/new/%s_%s.html' % (row['source'], row['version'])
                 # Warn about remaining information of prospective package
-                if ( dep.desc['en'] and dep.desc['en']['short'] ) or dep.properties['homepage'] != HOMEPAGENONE:
+                if (dep.desc['en'] and dep.desc['en']['short']) or dep.properties['homepage'] != HOMEPAGENONE:
                     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]
@@ -1719,7 +1755,7 @@ class TaskDependencies:
                         found = False
                         for vp in virtual_pkgs:
                             for pr in vp['provides'].split(','):
-                                prs=pr.strip()
+                                prs = pr.strip()
                                 if dep.pkg == prs:
                                     pkgs_virtual.append(prs)
                                     logger.info("Virtual package %s is provided by package %s for task %s" % (dep.pkg, vp['package'], dep.taskname))
@@ -1739,7 +1775,7 @@ class TaskDependencies:
         pkgs_in_vcs = []
         if curs.rowcount > 0:
             for row in RowDictionaries(curs):
-		# print row
+                # print row
                 pkgs_in_vcs.append(row['package'])
                 # seek for package name in list of packages mentioned in tasks file
                 found = False
@@ -1761,10 +1797,10 @@ class TaskDependencies:
                     status = 'pkgvcs'
                 dep.pkgstatus = status
                 dep.component = row['component']
-                dep.version   = [ row['version'], ]
-                dep.debtags   = [] # prevent trying to print debtags (should be default setting but does not work in template (FIXME)
+                dep.version   = [row['version']]
+                dep.debtags   = []  # prevent trying to print debtags (should be default setting but does not work in template (FIXME)
                 # Warn about remaining information of prospective package
-                if ( dep.desc['en'] and dep.desc['en']['short'] ) or dep.properties['homepage'] != HOMEPAGENONE:
+                if (dep.desc['en'] and dep.desc['en']['short']) or dep.properties['homepage'] != HOMEPAGENONE:
                     logger.info("The package %s is not yet in Debian but it is just in Blends %s Vcs. (Task %s)" % (dep.pkg, row['blend'], dep.taskname))
                 for prop in PROPERTIES:
                     dep.properties[prop] = row[prop]
@@ -1814,7 +1850,7 @@ class TaskDependencies:
 
         for dependency in self.dependencies.keys():
             self.dependencies[dependency].sort()
-        return 1 # Success
+        return 1  # Success
 
     def _QueryUDD4Package(self, source):
 
@@ -1835,7 +1871,6 @@ class TaskDependencies:
                 self.properties['stable_testing_version'].append((row['release'], row['debversion'], row['version'], prefix))
                 prefix = ', '
 
-
         if has_official == 1:
             if self.component == 'main':
                 if self.dep_strength == 'Depends' or self.dep_strength == 'Recommends':
@@ -1847,7 +1882,6 @@ class TaskDependencies:
         else:
             self.pkgstatus = 'experimental'
 
-
         if 'source' in self.properties:
             query = "EXECUTE src_vcs ('%s')" % (self.properties['source'])
             _execute_udd_query(query)
@@ -1877,53 +1911,52 @@ class TaskDependencies:
             logger.error("Failed to obtain source for package", self.pkg)
             return
 
-        if source == 0: # If we are querying for source packages to render BTS pages
-                # tranlations are irrelevant - so only obtain ddtp translations
-                # otherwise
-
-######################
-                if flag == 0:
-                    # If there was no such package found query UDD whether any package provides this name
-                    # This is often the case for libraries with versions in the package name
-                    query = "EXECUTE query_provides ('%s')" % (dep.pkg)
-                    _execute_udd_query(query)
-                    if curs.rowcount > 0:
-                        has_expilicite = 0
-                        VirtProvides = []
-                        for row in curs.fetchall():
-                            VirtProvides.append(row[0])
-                            for hasdeps in tmp_dep_list:
-                                if row[0] == hasdeps.pkg:
-                                    logger.error("    --> %s is mentioned explicitely in dependency list" % row[0])
-                                    has_expilicite = 1
-                        if has_expilicite == 1:
-                            logger.error("Do not keep a record of virtual package %s which has explicite package dependencies" % dep.pkg)
-                            # ATTENTION: THIS HAS TO BE CHANGED FOR blends-dev BY AN OPTIONAL parameter
-#                            continue
-
-                        logger.error("Use real package %s instead of virtual package %s." % (VirtProvides[0], dep.pkg))
-                        dep.pkg = VirtProvides[0]
-                        dep._QueryUDD4Package(source)
-
-                        if len(VirtProvides) > 1:
-                            logger.error("Virtual package %s is provided by more than one package (%s).  Make sure you mention a real package in addition!" \
-                                % (dep.pkg, str(VirtProvides)))
-
-                            for virt_provides in VirtProvides[1:]:
-                                # Add all remaining packages which provide a virtual package to the list
-                                if dep != None:
-                                    # Add the first real package from the packages which provide the virtual package to the list
-                                    tmp_dep_list.append(dep)
-                                dep = DependantPackage(self.blendname, self.task)
-                                # Store the comments in case they might be usefull for later applications
-                                dep.why            = why
-                                dep.responsible    = responsible
-                                dep.dep_strength   = key
-                                dep.pkg            = virt_provides
-                                dep._QueryUDD4Package(source)
-                    else:
-                        logger.warning("Dependency with unknown status: %s (Task %s)" % (dep.pkg, dep.taskname))
-
+        if source == 0:
+            # If we are querying for source packages to render BTS pages
+            # tranlations are irrelevant - so only obtain ddtp translations
+            # otherwise
+            ######################
+            if flag == 0:
+                # If there was no such package found query UDD whether any package provides this name
+                # This is often the case for libraries with versions in the package name
+                query = "EXECUTE query_provides ('%s')" % (dep.pkg)
+                _execute_udd_query(query)
+                if curs.rowcount > 0:
+                    has_expilicite = 0
+                    VirtProvides = []
+                    for row in curs.fetchall():
+                        VirtProvides.append(row[0])
+                        for hasdeps in tmp_dep_list:
+                            if row[0] == hasdeps.pkg:
+                                logger.error("    --> %s is mentioned explicitely in dependency list" % row[0])
+                                has_expilicite = 1
+                    if has_expilicite == 1:
+                        logger.error("Do not keep a record of virtual package %s which has explicite package dependencies" % dep.pkg)
+                        # ATTENTION: THIS HAS TO BE CHANGED FOR blends-dev BY AN OPTIONAL parameter
+#                        continue
+
+                    logger.error("Use real package %s instead of virtual package %s." % (VirtProvides[0], dep.pkg))
+                    dep.pkg = VirtProvides[0]
+                    dep._QueryUDD4Package(source)
+
+                    if len(VirtProvides) > 1:
+                        logger.error("Virtual package %s is provided by more than one package (%s).  Make sure you mention a real package in addition!"
+                                     % (dep.pkg, str(VirtProvides)))
+
+                        for virt_provides in VirtProvides[1:]:
+                            # Add all remaining packages which provide a virtual package to the list
+                            if dep is not None:
+                                # Add the first real package from the packages which provide the virtual package to the list
+                                tmp_dep_list.append(dep)
+                            dep = DependantPackage(self.blendname, self.task)
+                            # Store the comments in case they might be usefull for later applications
+                            dep.why            = why
+                            dep.responsible    = responsible
+                            dep.dep_strength   = key
+                            dep.pkg            = virt_provides
+                            dep._QueryUDD4Package(source)
+                else:
+                    logger.warning("Dependency with unknown status: %s (Task %s)" % (dep.pkg, dep.taskname))
 
         for dependency in self.dependencies.keys():
             self.dependencies[dependency].sort()
@@ -1934,11 +1967,11 @@ class TaskDependencies:
 
         for dependency in self.dependencies.keys():
             for dep in self.dependencies[dependency]:
-                dep.responsible         = MarkupString(dep.responsible, dep.pkg, 'responsible')
+                dep.responsible = MarkupString(dep.responsible, dep.pkg, 'responsible')
                 if dep.desc['en'] != {}:
                     dep.desc['en']['short'] = MarkupString(dep.desc['en']['short'], dep.pkg, 'pkgShortDesc')
                     try:
-                        dep.desc['en']['long']  = MarkupString(dep.desc['en']['long'],  dep.pkg, 'pkgLongDesc')
+                        dep.desc['en']['long'] = MarkupString(dep.desc['en']['long'], dep.pkg, 'pkgLongDesc')
                     except KeyError:
                         logger.error("Dep has no English long description: %s", dep.pkg)
                         dep.desc['en']['long'] = "??? Missing long description for package %s" % dep.pkg
@@ -1960,7 +1993,7 @@ class Available:
     #                          source=1             # Use source package names, default: use binaries
     #                          arch='sparc'         # (default='i386')
     #                         )
-    # 
+    #
     #    available.GetPackageNames() # Actually parse the Packages files to obtain needed information
     #                                # This has to be done at least once.  It is verified that the effort
     #                                # to obtain package information is not done twice per run
@@ -1971,20 +2004,19 @@ class Available:
         else:
             self.__init_Packages_gz__(release=release, components=components, source=source, arch=arch)
 
-
     def __init_Packages_gz__(self, release=None, components=(), source=None, arch=None):
-        self.source = 'Packages.'+COMPRESSIONEXTENSION
-        if source != None:
-            self.source = 'Sources.'+COMPRESSIONEXTENSION
+        self.source = 'Packages.' + COMPRESSIONEXTENSION
+        if source is not None:
+            self.source = 'Sources.' + COMPRESSIONEXTENSION
         self.binary = 'source'
-        if source == None:
-            if arch == None:
+        if source is None:
+            if arch is None:
                 # use arch=i386 as default because it contains most packages
                 self.binary = 'binary-i386'
             else:
                 self.binary = 'binary-' + arch
         self.release = 'unstable'
-        if release != None:
+        if release is not None:
             self.release = release
         self.components = ('main', 'contrib', 'non-free')
         if components != ():
@@ -2011,6 +2043,7 @@ _execute_udd_query(query)
 query = """PREPARE bugs_query_tags (int) AS SELECT tag FROM bugs_tags WHERE id = $1"""
 _execute_udd_query(query)
 
+
 class BugEntry:
     # Define a separate class for bug entries to be able to define a reasonably sorting mechanism
     # It seems that Genshi templates are unable to handle bug objects and so the essential parts
@@ -2021,8 +2054,8 @@ class BugEntry:
 
     def __init__(self, bug):
         self.bug      = bug['id']
-	self.summary  = bug['title']
-	self.severity = bug['severity']
+        self.summary  = bug['title']
+        self.severity = bug['severity']
 
         query = "EXECUTE bugs_query_tags (%i)" % self.bug
         _execute_udd_query(query)
@@ -2031,17 +2064,18 @@ class BugEntry:
         if curs.rowcount > 0:
             komma = ''
             for tag in curs.fetchall():
-		self.tags += komma + tag[0]
-		komma = ', '
+                self.tags += komma + tag[0]
+                komma = ', '
 
     # sort these objects according to bug number
     def __cmp__(self, other):
         # Comparing with None object has to return something reasonable
-        if other == None:
+        if other is None:
             return -2
         # Sort according to package name
         return cmp(self.bug, other.bug)
 
+
 class PackageBugs:
     # Store list of bugs (either open or done) of a package
 
@@ -2051,25 +2085,25 @@ class PackageBugs:
         self.homepage   = pkgdict['homepage']
         self.vcsbrowser = pkgdict['vcs-browser']
         self.maintainer = MarkupString(pkgdict['maintainer'], self.pkgname, 'maintainer')
-	self.bugs       = []      # open bugs
-	self.nbugs      = 0
-	self.severities = {}
-	for s in SEVERITIES:
-		self.severities[s] = 0
+        self.bugs       = []      # open bugs
+        self.nbugs      = 0
+        self.severities = {}
+        for s in SEVERITIES:
+                self.severities[s] = 0
 
     # sort these objects according to the package name
     def __cmp__(self, other):
         # Comparing with None object has to return something reasonable
-        if other == None:
+        if other is None:
             return -2
         # Sort according to package name
         return cmp(self.pkgname, other.pkgname)
 
     def __str__(self):
         str = "---\npkgname: %s\nsource: %s\n" % (self.pkgname, self.source)
-	if self.homepage:
+        if self.homepage:
             str += "homepage: %s\n" % (self.homepage)
-	if self.vcsbrowser:
+        if self.vcsbrowser:
             str += "vcsbrowser: %s\n" % (self.vcsbrowser)
         return str + "nbugs: %s\nnbugs = %i\nseverities = %s\n---" % (self.nbugs, self.severities)
 
@@ -2078,12 +2112,12 @@ class PackageBugsOpenAndDone:
     # Store list of bugs of a package
 
     def __init__(self, pkgdict):
-	pkgname = pkgdict['pkgname']
-	source  = pkgdict['source']
-	self.open       = PackageBugs(pkgdict)  # open bugs
-	self.done       = PackageBugs(pkgdict)  # closed bugs
+        pkgname = pkgdict['pkgname']
+        source  = pkgdict['source']
+        self.open       = PackageBugs(pkgdict)  # open bugs
+        self.done       = PackageBugs(pkgdict)  # closed bugs
 
-	bugs = None
+        bugs = None
         query = "EXECUTE bugs_query_source ('%s')" % source
         _execute_udd_query(query)
 
@@ -2091,22 +2125,21 @@ class PackageBugsOpenAndDone:
             for bug in RowDictionaries(curs):
                 bugentry = BugEntry(bug)
                 if bug['status'] == 'done':
-                    if self.done.pkgname == None:
+                    if self.done.pkgname is None:
                         self.done.pkgname = pkgname
                     self.done.bugs.append(bugentry)
                     self.done.nbugs += 1
                 else:
-                    if self.open.pkgname == None:
+                    if self.open.pkgname is None:
                         self.open.pkgname = pkgname
                     self.open.bugs.append(bugentry)
                     self.open.nbugs += 1
                     self.open.severities[bugentry.severity] += 1
             self.open.bugs.sort()
             self.done.bugs.sort()
-            if source == None:
+            if source is None:
                 self.open.source = pkgname
                 self.done.source = pkgname
             else:
                 self.open.source = source
                 self.done.source = source
-
diff --git a/webtools/bugs.py b/webtools/bugs.py
index af89f36..7089a2a 100755
--- a/webtools/bugs.py
+++ b/webtools/bugs.py
@@ -33,20 +33,20 @@ from blendsmarkdown  import MarkupString
 ###########################################################################################
 # Define several prepared statements to query UDD
 try:
-  conn = psycopg2.connect(host="localhost",port=PORT,user="guest",database="udd")
+    conn = psycopg2.connect(host="localhost",port=PORT,user="guest",database="udd")
 except psycopg2.OperationalError, err:
-  try:
-    conn = psycopg2.connect("service=udd")
+    try:
+        conn = psycopg2.connect("service=udd")
   except psycopg2.OperationalError, err:
     # logger not known at this state: logger.warning
-    print >>stderr, "Service=udd seems not to be installed on this host.\tMessage: %s" % (str(err))
+    stderr.write("Service=udd seems not to be installed on this host.\tMessage: %s" % (str(err)))
     try:
         conn = psycopg2.connect(host="localhost",port=DEFAULTPORT,user="guest",database="udd")
     except psycopg2.OperationalError:
-	# Hmmm, I observed a really strange behaviour on one of my machines where connecting to
-	# localhost does not work but 127.0.0.1 works fine.  No idea why ... but this should
-	# do the trick for the moment
-	conn = psycopg2.connect(host="127.0.0.1",port=DEFAULTPORT,user="guest",database="udd")
+        # Hmmm, I observed a really strange behaviour on one of my machines where connecting to
+        # localhost does not work but 127.0.0.1 works fine.  No idea why ... but this should
+        # do the trick for the moment
+        conn = psycopg2.connect(host="127.0.0.1",port=DEFAULTPORT,user="guest",database="udd")
 
 curs = conn.cursor()
 # uddlog = open('logs/uddquery.log', 'w')
@@ -57,19 +57,18 @@ def _execute_udd_query(query):
         curs.execute(query)
         elapsed_time = time.time() - t
         if elapsed_time > SLOWQUERYREPORTLIMIT: # report what query took longer than SLOWQUERYREPORTLIMIT seconds
-            print "Time: %s\nQuery: %s" % (str(elapsed_time), query)
+            print("Time: %s\nQuery: %s" % (str(elapsed_time), query))
     except psycopg2.ProgrammingError, err:
-        print >>stderr, "Problem with query\n%s" % (query)
-        print >>stderr, err
+        stderr.write("Problem with query\n%s\n%s\n" % (query, str(err)))
         exit(-1)
     except psycopg2.DataError, err:
-        print >>stderr, "%s; query was\n%s" % (err, query)
+        stderr.write("%s; query was\n%s\n" % (err, query))
 
 
 def main():
 
     if len(argv) <= 1:
-        print >>stderr, "Usage: %s <Blend name>" % argv[0]
+        stderr.write("Usage: %s <Blend name>\n" % argv[0])
         exit(-1)
 
     blendname = argv[1]
@@ -146,14 +145,14 @@ def main():
                'normal'    :  3,
                'minor'     :  1,
                'wishlist'  :  0
-             }
+    }
     BAD          = 100 # if weighted bug sum >= BAD, the meta package is in a bad shape
-                       # Dependent packages might have 3 or more 5 RC bugs
+    # Dependent packages might have 3 or more 5 RC bugs
     PASS         =  70 # this deserves a look - potentially two RC bugs in dependent packages
-    SATISFACTORY =  50 # consider looking at this
-    GOOD         =  30 # at least no RC bug in a dependent package
-    VERYGOOD     =  10 # nothing burning
-    EXCELLENT    =   5 # There is no real need to look at this meta package
+SATISFACTORY =  50 # consider looking at this
+GOOD         =  30 # at least no RC bug in a dependent package
+VERYGOOD     =  10 # nothing burning
+EXCELLENT    =   5 # There is no real need to look at this meta package
 
     # initialise bugs_data dictionary for all tasks
     _execute_udd_query( "EXECUTE query_get_tasks('%s')" % blendname)
@@ -162,12 +161,12 @@ def main():
         for t in RowDictionaries(curs):
             task = t['task']
             bugs_data[task] = {}
-            bugs_data[task]['title']		= t['title']
-            bugs_data[task]['description']	= t['description']
-            bugs_data[task]['long_description']	= t['long_description']
-            bugs_data[task]['nopenbugs']	= 0
-            bugs_data[task]['ndonebugs']	= 0
-            bugs_data[task]['weighttask']	= 0
+            bugs_data[task]['title']            = t['title']
+            bugs_data[task]['description']      = t['description']
+            bugs_data[task]['long_description'] = t['long_description']
+            bugs_data[task]['nopenbugs']        = 0
+            bugs_data[task]['ndonebugs']        = 0
+            bugs_data[task]['weighttask']       = 0
             for status in STATES:
                 bugs_data[task][status + '_l']     = [] # enable sorting
                 bugs_data[task][status]            = {}
@@ -178,7 +177,7 @@ def main():
                     for s in SEVERITIES:
                         bugs_data[task][status]['severities'][s] = 0
     else:
-        print >>stderr, "No tasks metadata received for Blend", blendname
+        stderr.write("No tasks metadata received for Blend %s\n" % blendname)
         exit(1)
 
     # Fetch bugs of all Blends dependencies and store them in a dictionary
@@ -191,11 +190,11 @@ def main():
                 bugs[bug['source']]['severities'] = {}
                 for s in SEVERITIES:
                     bugs[bug['source']]['severities'][s] = 0
-                bugs[bug['source']]['nopenbugs'] = 0
-                bugs[bug['source']]['ndonebugs'] = 0
-                bugs[bug['source']]['open'] = []
-                bugs[bug['source']]['done'] = []
-            b = {}
+                    bugs[bug['source']]['nopenbugs'] = 0
+                    bugs[bug['source']]['ndonebugs'] = 0
+                    bugs[bug['source']]['open'] = []
+                    bugs[bug['source']]['done'] = []
+                    b = {}
             for k in bug.keys():
                 if k in ('source', 'status') :
                     continue
@@ -206,8 +205,8 @@ def main():
                     b['tags'] = ''
                     if bug[k]:
                         for tag in bug[k]:
-                           b['tags'] += komma + tag
-                           komma      = ', '
+                            b['tags'] += komma + tag
+                            komma      = ', '
                 else:
                     b[k] = bug[k]
             if bug['status'] == 'done':
@@ -218,22 +217,22 @@ def main():
                 bugs[bug['source']]['nopenbugs'] += 1
                 bugs[bug['source']]['severities'][bug['severity']] += 1
     else:
-        print >>stderr, "No bug data received for Blend", blendname
+        stderr.write("No bug data received for Blend %s\n" % blendname)
         exit(1)
 
     # Merge metadata of packages and bugs together in bugs_data dictionary, also do statistics about bugs
     _execute_udd_query( "EXECUTE query_bug_packages('%s')" % blendname)
     if curs.rowcount > 0:
         for pkg in RowDictionaries(curs):
-                task = pkg['task']
-                sources = {}
-                sources['source']      = pkg['source']
-                sources['homepage']    = pkg['homepage']
-                sources['vcs_browser'] = pkg['vcs_browser']
-                (_name, _url) = email.Utils.parseaddr(pkg['maintainer'])
-                sources['maintainer_email'] = _url
-                sources['maintainer_name']  = _name
-                sources['maintainer']  = MarkupString('<a href="mailto:%s">%s</a>' % (_url, _name), pkg['source'], 'maintainer')
+            task = pkg['task']
+            sources = {}
+            sources['source']      = pkg['source']
+            sources['homepage']    = pkg['homepage']
+            sources['vcs_browser'] = pkg['vcs_browser']
+            (_name, _url) = email.Utils.parseaddr(pkg['maintainer'])
+            sources['maintainer_email'] = _url
+            sources['maintainer_name']  = _name
+            sources['maintainer']  = MarkupString('<a href="mailto:%s">%s</a>' % (_url, _name), pkg['source'], 'maintainer')
                 if pkg['status'] == 'depends':
                     sources['bugs'] = bugs[pkg['source']]['open']
                     bugs_data[task][pkg['status']+'_l'].append(pkg['source'])
@@ -247,11 +246,12 @@ def main():
                         bugs_data[task][pkg['status']]['severities'][s] += bugs[pkg['source']]['severities'][s]
                         bugs_data[task]['weighttask'] += 1 * WEIGHT[s] * bugs[pkg['source']]['severities'][s]
                 else:
-                    print >>stderr, "%s: Wrong status %s in task %s for source %s" % (blendname, pkg['status'], task, pkg['source'])
+                    stderr.write("%s: Wrong status %s in task %s for source %s\n"
+                                 % (blendname, pkg['status'], task, pkg['source']))
                     exit(1)
-                bugs_data[task][pkg['status']]['sources'].append(sources)
-                bugs_data[task]['nopenbugs'] += bugs[pkg['source']]['nopenbugs']
-                bugs_data[task]['ndonebugs'] += bugs[pkg['source']]['ndonebugs']
+                    bugs_data[task][pkg['status']]['sources'].append(sources)
+                    bugs_data[task]['nopenbugs'] += bugs[pkg['source']]['nopenbugs']
+                    bugs_data[task]['ndonebugs'] += bugs[pkg['source']]['ndonebugs']
                 if bugs[pkg['source']]['done']:
                     sources = {}
                     sources['source']      = pkg['source']
@@ -265,7 +265,7 @@ def main():
                     bugs_data[task]['done_l'].append(pkg['source'])
                     bugs_data[task]['done']['sources'].append(sources)
     else:
-        print >>stderr, "No information about buggy packages received for Blend", blendname
+        stderr.write("No information about buggy packages received for Blend %s\n" % blendname)
         exit(1)
 
     # Define directories used
@@ -279,8 +279,8 @@ def main():
     
     outputdir = CheckOrCreateOutputDir(config['outputdir'],'bugs') # FIXME: as long as we are not finished use different dir
     if outputdir == None:
-            exit(-1)
-    
+        exit(-1)
+        
     t = datetime.now()
     
     # Initialize i18n
@@ -304,7 +304,7 @@ def main():
     data['idxsummary']        = _("""A %sDebian Pure Blend%s is a Debian internal project which assembles
 a set of packages that might help users to solve certain tasks of their work.  The list on
 the right shows the tasks of %s.""" ) \
-                                      % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
+% ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
     data['idxsummary']        = Markup(data['idxsummary'])
 
     t = datetime.now()
@@ -322,7 +322,7 @@ the right shows the tasks of %s.""" ) \
     a set of packages that might help users to solve certain tasks of their work.  This page should be helpful
     to track down the bugs of packages that are interesting for the %s project to enable developers a quick
     overview about possible problems.""" ) \
-                                          % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
+    % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
     data['bugssummary']        = Markup(data['bugssummary'])
     data['gtstrBugsPage']     = _("Bugs page")
     data['gtstrListOfBugspages'] = _("This is a list of metapackages.  The links are leading to the respective bugs page.")
@@ -342,7 +342,7 @@ the right shows the tasks of %s.""" ) \
                                 (SATISFACTORY, 'satisfactory'),
                                 (PASS,         'pass'),
                                 (BAD,          'bad')
-                              ]
+    ]
     
     for task in bugs_data:
         if bugs_data[task]['weighttask'] < data['assessments'][0][0]:
@@ -363,22 +363,21 @@ the right shows the tasks of %s.""" ) \
         else:
             bugs_data[task]['weightedsev']   = _('Immediately looking into bugs of the dependencies of this task is advised')
             bugs_data[task]['weightedclass'] = data['assessments'][5][1]
-        bugs_data[task]['weightedsev']   +=  ' (%i)' % bugs_data[task]['weighttask']
+            bugs_data[task]['weightedsev']   +=  ' (%i)' % bugs_data[task]['weighttask']
 
     # Debuging output in JSON file
     if debug > 0:
-        f = open(blendname+'_bugs.json', 'w')
-        if debug > 1:
+        with open(blendname+'_bugs.json', 'w') as f:
+          if debug > 1:
             for task in bugs_data:
-                print >>f, "*** %s ***" % task
+                f.write("*** %s ***\n" % task)
                 for status in STATES:
                     if status in bugs_data[task]:
-                        print >>f, status
-                        print >>f, json.dumps(bugs_data[task][status])
-                print >>f
-        print >>f, json.dumps(bugs_data)
-        f.close()
-        SetFilePermissions(blendname+'_bugs.json')
+                        f.write("%s\n" % status)
+                        f.write(json.dumps(bugs_data[task][status]))
+                        f.write("\n\n")
+                        f.write(json.dumps(bugs_data))
+                        SetFilePermissions(blendname+'_bugs.json')
 
     nbugs           = {}
     ndone           = {}
@@ -389,51 +388,51 @@ the right shows the tasks of %s.""" ) \
     
     wsev = 0  # sumarise weighted severities
     for task in bugs_data:
-    	for status in STATES:
+        for status in STATES:
             if status != 'done':
                 komma  = ''
                 for s in SEVERITIES:
-    		     if bugs_data[task][status]['severities'][s] != 0:
-    		        bugs_data[task][status]['severitysummary'] += '%s %i %s' % (komma, bugs_data[task][status]['severities'][s], s)
-    		        komma = ','
-    	if   wsev < data['assessments'][0][0]:
-    		weightedsev[task]   = _('Metapackage is in excellent shape')
-    		weightedclass[task] = data['assessments'][0][1]
-    	elif wsev < data['assessments'][1][0]:
-    		weightedsev[task]   = _('Metapackage is in very good shape')
-    		weightedclass[task] = data['assessments'][1][1]
-    	elif wsev < data['assessments'][2][0]:
-    		weightedsev[task]   = _('Metapackage is in good shape')
-    		weightedclass[task] = data['assessments'][2][1]
-    	elif wsev < data['assessments'][3][0]:
-    		weightedsev[task]   = _('Consider looking into bugs of this metapackage')
-    		weightedclass[task] = data['assessments'][3][1]
-    	elif wsev < data['assessments'][4][0]:
-    		weightedsev[task]   = _('Looking into bugs of this metapackage is recommended')
-    		weightedclass[task] = data['assessments'][4][1]
-    	else:
-    		weightedsev[task]   = _('Immediately looking into bugs of the dependencies of this metapackage is advised')
-    		weightedclass[task] = data['assessments'][5][1]
-    	weightedsev[task] += ' (%i)' % wsev
-    	weighttask[task]   = wsev
-    
+                     if bugs_data[task][status]['severities'][s] != 0:
+                         bugs_data[task][status]['severitysummary'] += '%s %i %s' % (komma, bugs_data[task][status]['severities'][s], s)
+                         komma = ','
+        if   wsev < data['assessments'][0][0]:
+            weightedsev[task]   = _('Metapackage is in excellent shape')
+            weightedclass[task] = data['assessments'][0][1]
+        elif wsev < data['assessments'][1][0]:
+            weightedsev[task]   = _('Metapackage is in very good shape')
+            weightedclass[task] = data['assessments'][1][1]
+        elif wsev < data['assessments'][2][0]:
+            weightedsev[task]   = _('Metapackage is in good shape')
+            weightedclass[task] = data['assessments'][2][1]
+        elif wsev < data['assessments'][3][0]:
+            weightedsev[task]   = _('Consider looking into bugs of this metapackage')
+            weightedclass[task] = data['assessments'][3][1]
+        elif wsev < data['assessments'][4][0]:
+            weightedsev[task]   = _('Looking into bugs of this metapackage is recommended')
+            weightedclass[task] = data['assessments'][4][1]
+        else:
+            weightedsev[task]   = _('Immediately looking into bugs of the dependencies of this metapackage is advised')
+            weightedclass[task] = data['assessments'][5][1]
+            weightedsev[task] += ' (%i)' % wsev
+            weighttask[task]   = wsev
+            
     data['headings'] = {'dependent' : _('Open bugs in dependent packages'),
                         'suggested' : _('Open bugs in suggested packages'),
                         'done'      : _('Done bugs')
-                       }
+    }
     data['nobugs']   = {'dependent' : _('No open bugs in dependent packages'),
                         'suggested' : _('No open bugs in suggested packages'),
                         'done'      : _('No done bugs')
-                       }
+    }
     data['cssclass'] = {'dependent' : 'bugsdependent',
                         'suggested' : 'bugssuggested',
                         'done'      : 'bugsdone'
-                       }
+    }
     # FIXME: just always use 'depends' or 'dependent' etc.  This translation is just to be able to compare with old output
     data['category'] = {'depends'   : 'dependent',
                         'suggests'  : 'suggested',
                         'done'      : 'done'
-                       }
+    }
     
     data['nbugs']           = nbugs
     data['ndone']           = ndone
@@ -449,23 +448,23 @@ the right shows the tasks of %s.""" ) \
 
     for key in ('css', 'homepage', 'projecturl', 'projectname', 'logourl', 'ubuntuhome', 'projectubuntu'):
         data[key] = config[key]
-    
+        
     for task in bugs_data:
-    	data['task']            = task
-    	#data['buglist']         = buglist[task]
-    	#data['weightedsev']     = weightedsev[task]
-    	#data['severitystat']    = severitystat[task]
-    
-    	template = loader.load('bugs.xhtml')
-    	with codecs.open(outputdir + '/' + task + '.html', 'w', 'utf-8') as f:
-          f.write(template.generate(**data).render('xhtml'))
-        SetFilePermissions(outputdir + '/' + task + '.html')
-    
+        data['task']            = task
+        #data['buglist']         = buglist[task]
+        #data['weightedsev']     = weightedsev[task]
+        #data['severitystat']    = severitystat[task]
+        
+        template = loader.load('bugs.xhtml')
+        with codecs.open(outputdir + '/' + task + '.html', 'w', 'utf-8') as f:
+            f.write(template.generate(**data).render('xhtml'))
+            SetFilePermissions(outputdir + '/' + task + '.html')
+            
     template = loader.load('bugs_idx.xhtml')
     outputfile = outputdir + '/index.html'
     with codecs.open(outputfile, 'w', 'utf-8') as f:
-      f.write(template.generate(**data).render('xhtml'))
-    SetFilePermissions(outputfile)
+        f.write(template.generate(**data).render('xhtml'))
+        SetFilePermissions(outputfile)
 
 if __name__ == '__main__':
     main()
diff --git a/webtools/ddpo_register.py b/webtools/ddpo_register.py
index 34f65e5..7dadd06 100755
--- a/webtools/ddpo_register.py
+++ b/webtools/ddpo_register.py
@@ -8,22 +8,25 @@ from sys import argv, exit, stderr
 from blendstasktools import Tasks
 
 if len(argv) <= 1:
-	print >>stderr, "Usage: %s <Blend name>\n       The <Blend name> needs a matching config file webconf/<Blend name>.conf"\
-                        % argv[0]
-	exit(-1)
+    stderr.write("Usage: %s <Blend name>\n" +
+                 "       The <Blend name> needs a matching config file webconf/<Blend name>.conf\n"
+                 % argv[0])
+    exit(-1)
 
 tasks  = Tasks(argv[1])
 if tasks.data['pkglist'] == '':
-	print >>stderr, "Config file webconf/%s.conf is lacking pkglist field." % (argv[1])
-	exit(-1)
+    stderr.write("Config file webconf/%s.conf is lacking pkglist field.\n"
+                 % argv[1])
+    exit(-1)
 tasks.GetAllDependencies(source=1)
-packages = tasks.GetNamesOnlyDict(dependencystatus=['official_high', 'official_low', 'non-free', 'experimental'])
+packages = tasks.GetNamesOnlyDict(dependencystatus=['official_high', 'official_low',
+                                                    'non-free', 'experimental'])
 
-print "user", tasks.data['pkglist']
+print("user %s" % tasks.data['pkglist'])
 for task in packages.keys():
-	for pkg in packages[task]:
-		print "subscribe %s %s" % ( pkg, task )
-print "thanks"
+    for pkg in packages[task]:
+        print("subscribe %s %s" % ( pkg, task ))
+print("thanks")
 
 
 # Perhaps we should also send a mail to pts at qa.debian.org
diff --git a/webtools/new_upstream.py b/webtools/new_upstream.py
index ca2e111..dc040d4 100755
--- a/webtools/new_upstream.py
+++ b/webtools/new_upstream.py
@@ -8,43 +8,43 @@ from sys import argv, exit, stderr
 from blendstasktools import Tasks
 
 if len(argv) <= 1:
-	print >>stderr, "Usage: %s <Blend name>\n       The <Blend name> needs a matching config file webconf/<Blend name>.conf"\
-                        % argv[0]
-	exit(-1)
+    stderr.write("Usage: %s <Blend name>\n       The <Blend name> needs a matching config file webconf/<Blend name>.conf\n"
+                 % argv[0])
+    exit(-1)
 
 tasks  = Tasks(argv[1])
 if tasks.data['pkglist'] == '':
-	print >>stderr, "Config file webconf/%s.conf is lacking pkglist field." % (argv[1])
-	exit(-1)
+    stderr.write("Config file webconf/%s.conf is lacking pkglist field.\n" % argv[1])
+    exit(-1)
 tasks.GetAllDependencies(source=1)
 packages = tasks.GetUpdatablePackages(dependencystatus=['official_high', 'official_low', 'non-free', 'experimental'])
 
 for task in packages.keys():
-	print "Updatable packages in Task", task
-	for pkg_v_o in packages[task]:
-		printstring = "\t%s:\n\t\tHighest version in Debian is %s\n\t\tUpstream has %s\n\t\tMaintainer is %s" % ( pkg_v_o[0] )
-		if pkg_v_o[1]:
-			printstring = printstring + "\n\t\tLast uploader was " + pkg_v_o[1]
-		try:
-			print printstring
-		except UnicodeEncodeError, err:
-			print "\t%s: (Problem printing UTF-8 data)\n\t\tHighest version in Debian is %s\n\t\tUpstream has %s\n" % \
-			    ( pkg_v_o[0][0], pkg_v_o[0][1], pkg_v_o[0][2] )
-			try:
-				print "type(pkg_v_o[0][3]) =", type(pkg_v_o[0][3])
-				print "type(pkg_v_o[1]) =", type(pkg_v_o[1])
-				# maintainerfield of package gnudatalanguage which is
-				#   Gürkan Sengün <gurkan at phys.ethz.ch>
-				# breaks print for some reason I do not understand because everything should be UTF-8
-				# error is: 'ascii' codec can't encode character u'\xfc' in position 104: ordinal not in range(128)
-				# just stick to the e-mail address to do something useful ...
-				print_wo_maintainer = pkg_v_o[0][3][0] # re.sub('^.+(<.+ at .+>.*)', '\\1', pkg_v_o[0][3])
-				print "\t\tMaintainer is ... %s" % ( print_wo_maintainer )
-				# print print_wo_maintainer[0:80]
-				if pkg_v_o[1]:
-					printstring = printstring + "\n\t\tLast uploader was " + pkg_v_o[1]
-			except:
-				pass
+    print("Updatable packages in Task %s" % task)
+    for pkg_v_o in packages[task]:
+        printstring = "\t%s:\n\t\tHighest version in Debian is %s\n\t\tUpstream has %s\n\t\tMaintainer is %s" % ( pkg_v_o[0] )
+        if pkg_v_o[1]:
+            printstring = printstring + "\n\t\tLast uploader was " + pkg_v_o[1]
+        try:
+            print(printstring)
+        except UnicodeEncodeError, err:
+            print("\t%s: (Problem printing UTF-8 data)\n\t\tHighest version in Debian is %s\n\t\tUpstream has %s\n" %
+                  (pkg_v_o[0][0], pkg_v_o[0][1], pkg_v_o[0][2]))
+            try:
+                print("type(pkg_v_o[0][3]) = %s\n" % type(pkg_v_o[0][3]).__name__)
+                print("type(pkg_v_o[1]) = %s\n" % type(pkg_v_o[1]).__name__)
+                # maintainerfield of package gnudatalanguage which is
+                #   Gürkan Sengün <gurkan at phys.ethz.ch>
+                # breaks print for some reason I do not understand because everything should be UTF-8
+                # error is: 'ascii' codec can't encode character u'\xfc' in position 104: ordinal not in range(128)
+                # just stick to the e-mail address to do something useful ...
+                print_wo_maintainer = pkg_v_o[0][3][0] # re.sub('^.+(<.+ at .+>.*)', '\\1', pkg_v_o[0][3])
+                print("\t\tMaintainer is ... %s\n" % print_wo_maintainer)
+                # print print_wo_maintainer[0:80]
+                if pkg_v_o[1]:
+                    printstring = printstring + "\n\t\tLast uploader was " + pkg_v_o[1]
+            except:
+                pass
 
 # Perhaps we should also send a mail to pts at qa.debian.org
 #     keyword %(pkg) %(list) = bts bts-control upload-source katie-other summary default cvs ddtp derivatives contact
diff --git a/webtools/tasks.py b/webtools/tasks.py
index 1205fd6..50e5238 100755
--- a/webtools/tasks.py
+++ b/webtools/tasks.py
@@ -23,8 +23,9 @@ from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sor
 from blendslanguages import languages, language_dict
 
 if len(argv) <= 1:
-    print >>stderr, "Usage: %s <Blend name>\n       The <Blend name> needs a matching config file webconf/<Blend name>.conf"\
-        % argv[0]
+    stderr.write("Usage: %s <Blend name>\n"+
+                 "       The <Blend name> needs a matching config file webconf/<Blend name>.conf\n"
+                 % argv[0])
     exit(-1)
 
 # LockBlendsTools() #  logger handler not defined at this moment, needs rethinking ... FIXME
@@ -224,7 +225,7 @@ for lang in languages:
                     if lang == 'en':
                         # ... but only once and not per language
                         for dep in tasks.tasks[task].dependencies[status]:
-                            print >>stderr, "Warning: Dependency with unknown status:", dep.pkg
+                            stderr.write("Warning: Dependency with unknown status: %s\n" % dep.pkg)
                 else:
                     data['dependencies'][task].append(status)
                     if status in data['dependencies'][task]:
diff --git a/webtools/thermometer.py b/webtools/thermometer.py
index 5a3ed73..fc34325 100755
--- a/webtools/thermometer.py
+++ b/webtools/thermometer.py
@@ -33,14 +33,16 @@ except psycopg2.OperationalError, err:
     conn = psycopg2.connect("service=udd")
   except psycopg2.OperationalError, err:
     # logger not known at this state: logger.warning
-    print >>stderr, "Service=udd seems not to be installed on this host.\tMessage: %s" % (str(err))
+    stderr.write("Service=udd seems not to be installed on this host.\tMessage: %s\n" % (str(err)))
     try:
         conn = psycopg2.connect(host="localhost",port=DEFAULTPORT,user="guest",database="udd")
     except psycopg2.OperationalError:
-	# Hmmm, I observed a really strange behaviour on one of my machines where connecting to
-	# localhost does not work but 127.0.0.1 works fine.  No idea why ... but this should
-	# do the trick for the moment
-	conn = psycopg2.connect(host="127.0.0.1",port=DEFAULTPORT,user="guest",database="udd")
+        # Hmmm, I observed a really strange behaviour on one of my
+        # machines where connecting to localhost does not work but
+        # 127.0.0.1 works fine.  No idea why ... but this should do
+        # the trick for the moment
+        conn = psycopg2.connect(host="127.0.0.1", port=DEFAULTPORT, user="guest",
+                                database="udd")
 
 curs = conn.cursor()
 # uddlog = open('logs/uddquery.log', 'w')
@@ -49,17 +51,16 @@ def _execute_udd_query(query):
     try:
         curs.execute(query)
     except psycopg2.ProgrammingError, err:
-        print >>stderr, "Problem with query\n%s" % (query)
-        print >>stderr, err
+        stderr.write("Problem with query\n%s\n%s\n" % (query, str(err)))
         exit(-1)
     except psycopg2.DataError, err:
-        print >>stderr, "%s; query was\n%s" % (err, query)
+        stderr.write("%s; query was\n%s\n" % (str(err), query))
 
 
 def main():
 
     if len(argv) <= 1:
-        print >>stderr, "Usage: %s <Blend name>" % argv[0]
+        stderr.write("Usage: %s <Blend name>\n" % argv[0])
         exit(-1)
 
     blendname = argv[1]
@@ -74,7 +75,7 @@ def main():
         ubuntuprev1  = releasenames[1][0]
         ubuntuprev2  = releasenames[2][0]
     else:
-        print >>stderr, "Failed to obtain Ubuntu release names."
+        stderr.write("Failed to obtain Ubuntu release names.\n")
         exit(1)
 
     query = """PREPARE query_thermometer (text) AS
@@ -93,10 +94,10 @@ def main():
            -- map values from former dehs to upstream table values
            CASE WHEN d.status IS NULL OR
                      d.status = '' OR
-                     d.status = 'error'					THEN 'none'
-                WHEN d.status = 'Newer version available'		THEN 'outdated'
-                WHEN d.status = 'up to date'				THEN 'upToDate'
-                WHEN d.status = 'Debian version newer than remote site'	THEN 'newer-in-debian'
+                     d.status = 'error'                                 THEN 'none'
+                WHEN d.status = 'Newer version available'               THEN 'outdated'
+                WHEN d.status = 'up to date'                            THEN 'upToDate'
+                WHEN d.status = 'Debian version newer than remote site' THEN 'newer-in-debian'
                 ELSE 'unknown' -- should not occure!
            END AS upstreamstatus,
            homepage,
@@ -336,7 +337,7 @@ def main():
         #f.close()
         #SetFilePermissions(blendname+'_thermometer.json')
     else:
-        print >>stderr, "No data received for Blend", blendname
+        stderr.write"No data received for Blend %s\n" % blendname)
         exit(1)
 
     # Define directories used
@@ -412,16 +413,16 @@ the right shows the tasks of %s.""" ) \
     template = loader.load('thermometer.xhtml')
     with codecs.open(outputfile, 'w', 'utf-8') as f:
       try:
-        print >> f, template.generate(**data).render('xhtml')
+        f.write(template.generate(**data).render('xhtml'))
       except TypeError, err:
-        print >>stderr, "Problem creating thermometer.html.\tMessage: %s" % (str(err))
+        stderr.write("Problem creating thermometer.html.\tMessage: %s\n" % (str(err)))
     SetFilePermissions(outputfile)
     utemplate = loader.load('uthermometer.xhtml')
     with codecs.open(uoutputfile, 'w', 'utf-8') as f:
       try:
-        print >> f, utemplate.generate(**data).render('xhtml')
+        f.write(utemplate.generate(**data).render('xhtml'))
       except TypeError, err:
-        print >>stderr, "Problem creating uthermometer.html.\tMessage: %s" % (str(err))
+        stderr.write("Problem creating uthermometer.html.\tMessage: %s\n" % (str(err)))
     SetFilePermissions(uoutputfile)
 
 if __name__ == '__main__':

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list