Xqt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263175
Change subject: [DOC] Add doc strings to methods
......................................................................
[DOC] Add doc strings to methods
Change-Id: Ic28b614b5cd7fb4d484f5352469fdbb838115951
---
M scripts/templatecount.py
1 file changed, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/75/263175/1
diff --git a/scripts/templatecount.py b/scripts/templatecount.py
index 7f50cfe..1793233 100755
--- a/scripts/templatecount.py
+++ b/scripts/templatecount.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-This script will display the list of pages transcluding a given list of
templates.
+Display the list of pages transcluding a given list of templates.
It can also be used to simply count the number of pages (rather than
listing each individually).
@@ -31,8 +31,8 @@
"""
#
-# (C) Pywikibot team, 2006-2014
-# (C) xqt, 2009-2014
+# (C) Pywikibot team, 2006-2016
+# (C) xqt, 2009-2016
#
# Distributed under the terms of the MIT license.
#
@@ -53,6 +53,7 @@
@classmethod
def countTemplates(cls, templates, namespaces):
+ """Display number of transclusions for a list of templates."""
templateDict = cls.template_dict(templates, namespaces)
pywikibot.output(u'\nNumber of transclusions per template',
toStdout=True)
@@ -70,6 +71,7 @@
@classmethod
def listTemplates(cls, templates, namespaces):
+ """Display transcluded pages for a list of templates."""
templateDict = cls.template_dict(templates, namespaces)
pywikibot.output(u'\nList of pages transcluding templates:',
toStdout=True)
@@ -88,6 +90,14 @@
@classmethod
def template_dict(cls, templates, namespaces):
+ """
+ Create a dict of templates and its transcluded pages.
+
+ The names of the templates are the keys, and lists of pages
+ transcluding templates are the values.
+
+ @rtype: dict
+ """
gen = cls.template_dict_generator(templates, namespaces)
templateDict = {}
for template, transcludingArray in gen:
@@ -96,9 +106,12 @@
@staticmethod
def template_dict_generator(templates, namespaces):
+ """
+ Yield templates and a list of transcluded pages.
+
+ @rtype: generator
+ """
mysite = pywikibot.Site()
- # The names of the templates are the keys, and lists of pages
- # transcluding templates are the values.
mytpl = mysite.namespaces.TEMPLATE
for template in templates:
transcludingArray = []
--
To view, visit https://gerrit.wikimedia.org/r/263175
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic28b614b5cd7fb4d484f5352469fdbb838115951
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits