http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9896
Revision: 9896
Author: xqt
Date: 2012-02-14 08:19:34 +0000 (Tue, 14 Feb 2012)
Log Message:
-----------
Better print fromatting, that's what I wanted to
Modified Paths:
--------------
trunk/pywikipedia/templatecount.py
Modified: trunk/pywikipedia/templatecount.py
===================================================================
--- trunk/pywikipedia/templatecount.py 2012-02-14 08:02:54 UTC (rev 9895)
+++ trunk/pywikipedia/templatecount.py 2012-02-14 08:19:34 UTC (rev 9896)
@@ -50,7 +50,7 @@
def countTemplates(self, templates, namespaces):
mysite = pywikibot.getSite()
mytpl = mysite.template_namespace()+':'
- finalText = [u'Number of transclusions per template', u'-' * 36]
+ finalText = [u'', u'Number of transclusions per template',
u'-' * 36]
total = 0
# The names of the templates are the keys, and the numbers of
# transclusions are the values.
@@ -66,11 +66,11 @@
for page in gen:
count += 1
templateDict[template] = count
- finalText.append(u'%s: %d' % (template, count))
+ finalText.append(u'%-10s: %5d' % (template, count))
total += count
for line in finalText:
pywikibot.output(line, toStdout=True)
- pywikibot.output(u'TOTAL: %d' % total, toStdout=True)
+ pywikibot.output(u'TOTAL : %5d' % total, toStdout=True)
pywikibot.output(u'Report generated on %s'
% datetime.datetime.utcnow().isoformat(),
toStdout=True)