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

Akshita Jha akshita-guest at users.alioth.debian.org
Sat Jul 18 21:15:10 UTC 2015


The following commit has been merged in the master branch:
commit 0ddc2e2e42f72a2a4438caa9447d56cee80755f9
Author: Akshita Jha <akshita-guest at users.alioth.debian.org>
Date:   Sun Jul 19 02:44:38 2015 +0530

    Modify blendstasktools_udd.py and tasks_udd.py

diff --git a/webtools/blendstasktools_udd.py b/webtools/blendstasktools_udd.py
index de18f86..9be1fd4 100644
--- a/webtools/blendstasktools_udd.py
+++ b/webtools/blendstasktools_udd.py
@@ -574,17 +574,20 @@ def RowDictionaries(cursor):
     """Return a list of dictionaries which specify the values by their column names"""
 
     description = cursor.description
+    #print "Description : ",description
     if not description:
         # even if there are no data sets to return the description should contain the table structure.  If not something went
         # wrong and we return NULL as to represent a problem
+	#print "RETURNING NULL"
         return NULL
     if cursor.rowcount <= 0:
-        # if there are no rows in the cursor we return an empty list
+        #print "RETURNING []"
+	# if there are no rows in the cursor we return an empty list
         return []
 
     data = cursor.fetchall()
+    #print "data : ",data
     result = []
-
     for row in data:
         resultrow = {}
         i = 0
@@ -592,6 +595,7 @@ def RowDictionaries(cursor):
             resultrow[dd[0]] = row[i]
             i += 1
         result.append(resultrow)
+    #print "RETURNING RESULT"
     return result
 
 def BrowserFromVcsURL(vcs_type, vcs_url):
@@ -836,10 +840,10 @@ class Tasks:
                 translations = metapkg_translations[pkgname]
         
             td.SetMetapackageInfo(pkgname, translations)
-	    print "task : ",task
+	    # print "task : ",task
             if td.GetTaskDependencies(source):
                 self.tasks[task] = td
-        
+       		# print "I am in here ",self.tasks[task] 
             else: # Kick file that is obviously no task file from metapackage list
                 self.metapackagekeys = filter(lambda name: name != task, self.metapackagekeys)
 
@@ -970,6 +974,7 @@ class TaskDependencies:
     def SetMetapackageInfo(self, pkgname, ddtptranslations=None):
         # Gather information (specifically description translations if exists) about metapackage itself
         self.metapkg             = DependantPackage(self.blendname, self.task)
+	#print "self.metapkg", self.metapkg
         self.metapkg.pkg         = pkgname
         self.metapkg.source      = self.blendname
         if not ddtptranslations:
@@ -1000,9 +1005,24 @@ class TaskDependencies:
                                      (self.metapkg.pkg, lang, ddtptranslations['long_description_'+lang], err))
                     self.metapkg.desc[lang]['long'] = 'Missing long description'
 
-    def GetDepInfo(self, curs, dependencies):
-    
+
+    def _AppendDependency2List(self, dep):
+        # Append dependency which was found in the tasks file if not Ignore / Avoid and
+        # no dupplication in case of source depencencies
+        if dep == None:
+            return
+        if dep.dep_strength == 'Ignore' or dep.dep_strength == 'Avoid':
+            return
+        self.dependencies[dep.pkgstatus].append(dep)
+        return
+
+
+    def GetDepInfo(self, curs, dependencies): 
+
      	for row in RowDictionaries(curs):
+	    #for r in row:
+	    #	print r, ":", row[r]
+	
             # seek for package name in list of packages mentioned in tasks file
             found = False
             for dep in dependencies:
@@ -1025,21 +1045,42 @@ class TaskDependencies:
                 dep.pkgstatus = 'non-free'
             
             # if a package is released *only* in experimental decrease package status
-            if row['release'] == 'experimental':
-                dep.pkgstatus = 'experimental'
+            if 'release' in row and row['release'] == 'experimental':
+	        dep.pkgstatus = 'experimental'
 
             # dep.properties['license'] is already correct
             for prop in PROPERTIES:
                 dep.properties[prop] = row[prop]
                             
-            for prop in ('vcs-type', 'vcs-url'):
-                dep.properties[prop] = row[prop]
-                            
-            if row['vcs-browser']:
-                dep.properties['vcs-browser'] = row['vcs-browser']
-            else:
-                if dep.properties['vcs-browser'] == HOMEPAGENONE:
-                    dep.properties['vcs-browser'] = BrowserFromVcsURL(dep.properties['vcs-type'], dep.properties['vcs-url'])
+	    type_vcs = ''
+	    if 'vcs_type' in row :
+		type_vcs = 'vcs_type'
+	    elif 'vcs-type' in row:
+		type_vcs = 'vcs-type' 
+	    if type_vcs != '':
+	        dep.properties['vcs-type'] = row[type_vcs]
+		# print "vcs-type : ",dep.properties['vcs-type']
+
+	    type_url = ''
+	    if 'vcs_url' in row :
+		type_url = 'vcs_url'
+	    elif 'vcs-url' in row:
+		type_url = 'vcs-url' 
+	    if type_url != '':
+                dep.properties['vcs-url'] = row[type_url]
+		# print "vcs-url : ",dep.properties['vcs-url']
+
+	    type_browser = ''
+	    if 'vcs_browser' in row :
+		type_browser = 'vcs_browser'
+	    elif 'vcs-browser' in row:
+		type_browser = 'vcs-browser'
+	    if type_browser != '':
+                dep.properties['vcs-browser'] = row[type_browser]
+            elif dep.properties['vcs-browser'] == HOMEPAGENONE and type_vcs != '' and type_url != '':
+		 # print "\n################ROW###################\n",row
+                 dep.properties['vcs-browser'] = BrowserFromVcsURL(dep.properties['vcs-type'], dep.properties['vcs-url'])
+		 # print "vcs-browser after: ",dep.properties['vcs-browser']
 
             # enhances to be written
             # if row['enhanced']:
@@ -1047,16 +1088,19 @@ class TaskDependencies:
             #        dep.properties['Enhances'][pkg] = PKGURLMASK % pkg
             #        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.popcon['vote']   = row['vote']
-            dep.popcon['recent'] = row['recent']
-                            
 
+            if 'releases' in row:
+		for i in range(len(row['releases'])):
+                    dep.version.append({'release':row['releases'][i], 'version': row['versions'][i], 'archs':row['architectures'][i]})
+            
+	    if 'vote' in row:                
+                dep.popcon['vote']   = row['vote']
+	    if 'recent' in row:
+                dep.popcon['recent'] = row['recent']
+                           
             # Debtags as sorted list of dict fields
-            if row['debtags']:
+            if 'debtags' in row:
+	     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
                     logger.warning("Debtags for package '%s' was just set.  A duplicated result from database query is suspected.  Please check the result!" % dep.pkg)
                 tagdict = {}
@@ -1067,49 +1111,50 @@ class TaskDependencies:
                         tagdict[tag] += ', ' + value
                     else:
                         tagdict[tag]  = value
-                        taglist.append(tag)
-                    if taglist:
-                        taglist.sort()
+                    taglist.append(tag)
+                if taglist:
+                    taglist.sort()
                                 
                 for tag in taglist:
                     dep.debtags.append({'tag':tag, 'value':tagdict[tag]})
 
-                # screenshots
-                if row['icon']:
+            # screenshots
+            if 'icon' in row:
+		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]})
                                 
-                # it might be that the new upstream goes to experimental - this should be ignored here
+            # it might be that the new upstream goes to experimental - this should be ignored here
+	    if 'unstable_parsed_version' in row:
                 if row['unstable_parsed_version']:
                     dep.outdated['release']       = 'upstream'
                     dep.outdated['version']       = row['unstable_upstream']
                     dep.outdated['architectures'] = ''
 
-                if row['changed_by']:
+            if row['changed_by']:
+                try:
+                    changed = to_unicode(row['changed_by'])
+                except TypeError, err:
+                    changed = None
+                    logger.warning("Encoding problem for last uploader of package '%s' in task %s (%s)" % (dep.pkg, dep.taskname, err))
+                if changed:
                     try:
-                        changed = to_unicode(row['changed_by'])
-                    except TypeError, err:
-                        changed = None
-                        logger.warning("Encoding problem for last uploader of package '%s' in task %s (%s)" % (dep.pkg, dep.taskname, err))
-                    if changed:
-                        try:
-                            (_name, _url) = email.Utils.parseaddr(changed)
-                            changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
-                            dep.properties['changed_by']    = MarkupString(changed, dep.pkg, 'changed_by')                                
-                            dep.properties['last_uploader'] = to_unicode(changed)                                  
-                            dep.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
-                        except UnicodeDecodeError, err:
-                            logger.error("Encoding problem for last uploader - assume same as maintainer for package %s (%s)", dep.pkg, err)
-
-                # link to packages.debian.org search page to see overview about all
-                # package versions in all releases
-                # dep.properties['pkg-url'] = PKGURLMASK % dep.pkg
+                        (_name, _url) = email.Utils.parseaddr(changed)
+                        changed = '<a href="mailto:%s">%s</a>' % (_url, _name)
+                        dep.properties['changed_by']    = MarkupString(changed, dep.pkg, 'changed_by')                                
+                        dep.properties['last_uploader'] = to_unicode(changed)                                  
+                        dep.properties['last_uploader_simple'] = to_unicode('%s <%s>' % (_name, _url))
+                    except UnicodeDecodeError, err:
+                        logger.error("Encoding problem for last uploader - assume same as maintainer for package %s (%s)", dep.pkg, err)
+           # link to packages.debian.org search page to see overview about all
+           # package versions in all releases
+           # dep.properties['pkg-url'] = PKGURLMASK % dep.pkg
 
             for l in languages:
-                if row['description_'+l]:
+                if 'description_'+l in row and row['description_'+l] != None:
                     dep.desc[l] = {}
                     dep.desc[l]['short'] = MarkupString(to_unicode(row['description_'+l]), dep.pkg, 'ShortDesc')
                     if row['long_description_'+l]:
@@ -1120,15 +1165,16 @@ class TaskDependencies:
                     
                     (_name, _url) = email.Utils.parseaddr(row['maintainer'])
                     dep.properties['maintainer'] = to_unicode(row['maintainer'])
-                    dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name))                    
+                    dep.responsible = '<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name))
 
+	    self._AppendDependency2List(dep)
 
     def GetTaskDependencies(self, source=0):
         count = 0
         global dep_strength_keys
         dep = None
         alldepends = []         # contains the names of all the dependencies in a task file
-        dependencies = []
+        dependencies = []	# contains the all the info about a dependencies in a task file
 
         # Get the title and description of each task in a blend
         # Title, Description
@@ -1138,6 +1184,7 @@ class TaskDependencies:
             self.metapkg.PrintedName, short, long = curs.fetchone()
             # Markup strings to enable verbatim output of preformatted text
             self.metapkg.desc['en']['short'] = MarkupString(short.encode('utf-8'), self.metapkg.PrintedName, 'taskShortDesc')
+            long = long.decode('utf-8')
             self.metapkg.desc['en']['long']  = MarkupString(long.encode('utf-8'),  self.metapkg.PrintedName, 'taskLongDesc')
 
 
@@ -1147,7 +1194,8 @@ class TaskDependencies:
         _execute_udd_query(query)
         if curs.rowcount > 0:
             dep_info = curs.fetchall()
-            
+            #print "dep_info : ",dep_info
+	    #print 
             for each_dep in dep_info:
                 # class DependantPackage - This class contains all the possible information about a package
                 # Create an object of class DependantPackage
@@ -1157,44 +1205,28 @@ class TaskDependencies:
                 dep.pkg = each_dep[0]   # Name
                 # dep.license
                 dep.dep_strength = each_dep[1]  # Depends: 'd' or Suggests: 's'
-                
+               
                 alldepends.append(dep.pkg)
                 dependencies.append(dep)
                 #self.dependencies[dep.pkgstat].append(dep)
 
-	count = count +1
         query = "EXECUTE query_pkgs ('%s', '%s')" % (List2PgArray(alldepends), List2PgSimilarArray(alldepends))
         _execute_udd_query(query)
         if curs.rowcount > 0:
             self.GetDepInfo(curs, dependencies)
-
-	 
-      	print "+++++++++++++++++++++", count, self.task
+	    #print "+++++++++++++++++++++", self.task
 	
 
         # Get the package_name, license, dependency of the prospective dependencies of the task
-        query = "SELECT DISTINCT bp.package, bp.license, b.dependency, bp.component, bp.homepage, bp.section, \
-                        bp.source, bp.vcs_type, bp.vcs_url, bp.vcs_browser, bp.changed_by, \
-                        bp.uploaders, bp.maintainer, pop.vote, pop.recent, tags.debtags, bp.description, bp.long_description \
+        query = "SELECT DISTINCT bp.package, bp.license, b.dependency \
                 FROM blends_prospectivepackages bp JOIN blends_dependencies b ON b.blend=bp.blend \
-                LEFT OUTER JOIN popcon pop ON pop.package=bp.package \
-                LEFT OUTER JOIN ( \
-                SELECT package, array_agg(tag) AS debtags \
-                FROM debtags \
-                WHERE tag NOT LIKE 'implemented-in::%%' \
-                    AND tag NOT LIKE 'protocol::%%' \
-                    AND tag NOT LIKE '%%::TODO' \
-                    AND tag NOT LIKE '%%not-yet-tagged%%' \
-                GROUP BY package \
-                ) tags ON tags.package = bp.package \
                 WHERE bp.blend='%s' and b.task='%s'" % (self.blendname, self.task)
         _execute_udd_query(query)
 
         alldepends = []
         dependencies = []
         if curs.rowcount > 0:
-            pros_info = curs.fetchall()
-            #print pros_info
+            pros_info = curs.fetchall() 
 
             for each_pros in pros_info:
                 dep = DependantPackage(self.blendname, self.task)
@@ -1205,25 +1237,75 @@ class TaskDependencies:
                 
                 alldepends.append(dep.pkg)
                 dependencies.append(dep)
+	
+	    #print "alldepends prospective : ",alldepends
+	    #print "dependencies prospective : ",dependencies
 
+	query = "SELECT DISTINCT bp.package, bp.license, b.dependency, bp.component, bp.homepage, bp.section, \
+                        bp.source, bp.vcs_type, bp.vcs_url, bp.vcs_browser, bp.changed_by, \
+                        bp.uploaders, bp.maintainer, pop.vote, pop.recent, tags.debtags, bp.description AS description_en, bp.long_description AS long_description_en\
+                FROM blends_prospectivepackages bp JOIN blends_dependencies b ON b.blend=bp.blend \
+                LEFT OUTER JOIN popcon pop ON pop.package=bp.package \
+                LEFT OUTER JOIN ( \
+                SELECT package, array_agg(tag) AS debtags \
+                FROM debtags \
+                WHERE tag NOT LIKE 'implemented-in::%%' \
+                    AND tag NOT LIKE 'protocol::%%' \
+                    AND tag NOT LIKE '%%::TODO' \
+                    AND tag NOT LIKE '%%not-yet-tagged%%' \
+                GROUP BY package \
+                ) tags ON tags.package = bp.package \
+                WHERE bp.blend='%s' and b.task='%s'" % (self.blendname, self.task)
+        _execute_udd_query(query)
+        if curs.rowcount > 0:
+	    #print "going into getdepinfo from prospective : "
             self.GetDepInfo(curs, dependencies)
-	    print "-----------------", count, self.task
+	    #print "-----------------", self.task
 
 
         # Get information about new dependencies of the task
         query = "SELECT DISTINCT new.package FROM new_packages new JOIN blends_dependencies b ON b.package=new.package \
                 WHERE b.blend='%s' and b.task='%s'" % (self.blendname, self.task)
         _execute_udd_query(query)
-	pkgs_not_in_pool = []
+	alldepends = []
+	dependencies = []
+	pkgs_new = []
         if curs.rowcount > 0:
-            pkgs_not_in_pool = curs.fetchall()
-	
-        query = "EXECUTE query_new('%s')" % List2PgArray(pkgs_not_in_pool)
+            pkgs_new = curs.fetchall()
+	    # print "pkgs_new : ",pkgs_new
+	    for each_new_pkg in pkgs_new:
+                dep = DependantPackage(self.blendname, self.task)
+              
+                dep.pkg = each_new_pkg[0]          # Name
+                
+                alldepends.append(dep.pkg)
+                dependencies.append(dep)
+
+        query = "EXECUTE query_new('%s')" % List2PgArray(alldepends)
         _execute_udd_query(query)
-        pkgs_in_new = []
         if curs.rowcount > 0:
             self.GetDepInfo(curs, dependencies)
-	    print "xxxxxxxxxxxxxxxxxxx", count
+	    #print "xxxxxxxxxxxxxxxxxxx", self.task
+
+	return 1
 
+    def MarkupPreformatedStrings(self):
+        # Genshi does not touch strings that are marked with "Markup()" - so just
+        # mark the strings that are ready formatted
 
+        for dependency in self.dependencies.keys():
+            for dep in self.dependencies[dependency]:
+                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')
+                    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
 
+    def __str__(self):
+        ret = "Blend: " + self.blendname + ", " \
+              "Task:"   + self.task      + ", " \
+              "Dependencies:" + str(self.dependencies)
+        return ret
diff --git a/webtools/tasks_udd.py b/webtools/tasks_udd.py
index 06ae84a..ff8a216 100755
--- a/webtools/tasks_udd.py
+++ b/webtools/tasks_udd.py
@@ -30,10 +30,12 @@ if len(argv) <= 1:
 tasks    = Tasks(argv[1])
 tasks.GetAllDependencies()
 packages = tasks.GetNamesOnlyDict()
+#print "pacakges : \n", packages
 tasks.GetAllDependentPackagesOfBlend()
 tasks.MarkupPreformatedStringsBlend()
 
 data = tasks.data
+#print "data : \n",data
 data['tasks']            = tasks.GetTaskDescDict()
 data['taskskeys']        = tasks.metapackagekeys
 try:

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list