Commits

Anonymous committed ace6327

a few more comments, also use unicode for category names

  • Participants
  • Parent commits 04b4dfb

Comments (0)

Files changed (1)

 cat_quality = u"Catégorie:%s d'avancement %s"
 
 # names of importance/quality categories
-importance = ['maximum', u'élevée', 'moyenne', 'faible', 'inconnue']
-quality = ['AdQ', 'A', 'BA', 'B', 'BD', u'ébauche', 'inconnu']
+importance = [u'maximum', u'élevée', u'moyenne', u'faible', u'inconnue']
+quality = [u'AdQ', u'A', u'BA', u'B', u'BD', u'ébauche', u'inconnu']
 
 URLbase = u'http://toolserver.org/~bayo/intercat.php?'
 patURL = u'formCat1=%s d\'avancement %s&formCat2=%s d\'importance %s'
         results[project]['project'] = project
 
         total = 0
+        # first walk an importance axis
         for i, imp in enumerate(importance):
             catname = cat_importance % (prefix, imp)
             cat = pywikibot.Page(site, catname)
             results[project][43 + i] = u'[[:%s|{{formatnum:%s}}]]' % (catname, lenCat)
             total += lenCat
 
-        results[project]['total'] = total
-
-        t = pywikibot.Page(pywikibot.Link(u'Projet:%s/Total' % project))
-        putNb(t, total)
-
-        totalEval = total - len(artByCat[importance[-1]])
-        t = pywikibot.Page(pywikibot.Link(u'Projet:%s/Évaluation/Total évalué' % project))
-        putNb(t, totalEval)
-
-        results[project][48] = '{{formatnum:%s}}' % totalEval
-
+        # and then walk the quality axis
         for i, av in enumerate(quality):
             catname = cat_quality % (prefix, av)
             cat = pywikibot.Page(site, catname)
             results[project][6*(i + 1)] = u'[[:%s|{{formatnum:%s}}]]' % (catname, len(artByCat[av]))
 
 
+        # quote the prefix so it can be used in an URL
         if isinstance(prefix, unicode):
-            prefix = urllib.quote(prefix.encode('utf-8'))
+            prefix = prefix.encode('utf-8')
+        prefix = urllib.quote(prefix)
+
         i = 1
-        for av in quality:
-            if isinstance(av, unicode):
-                a = urllib.quote(av.encode('utf-8'))
-            else:
-                a = av
+        for qual in quality:
+            a = urllib.quote(qual.encode('utf-8'))
             for imp in importance:
-                if isinstance(imp, unicode):
-                    im = urllib.quote(imp.encode('utf-8'))
-                else:
-                    im = imp
+                im = urllib.quote(imp.encode('utf-8'))
                 inter = len(artByCat[av].intersection(artByCat[imp]))
                 if inter:
                     url = URLbase + patURL % (prefix, a, prefix, im)
 #        cPickle.dump(dict(articles), f)
 #        f.close()
 
+        # save total of articles in the project
+        t = pywikibot.Page(pywikibot.Link(u'Projet:%s/Total' % project))
+        putNb(t, total)
+
+        # and also save total of articles that have an evaluation
+        totalEval = total - len(artByCat[importance[-1]])
+        t = pywikibot.Page(pywikibot.Link(u'Projet:%s/Évaluation/Total évalué' % project))
+        putNb(t, totalEval)
+
+        results[project][48] = '{{formatnum:%s}}' % totalEval
+
+
     tl = u'<!-- BEGIN BOT SECTION -->'
     if type.lower() == 'simple':
         tl += u'{{Utilisateur:NicDumZ/Eval\n'