XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180691
Change subject: [IMPROV] Added some docstrings
......................................................................
[IMPROV] Added some docstrings
Change-Id: Ie5633447090ddfcf201ed38d7fea111a450c7177
---
M pywikibot/bot.py
M pywikibot/comms/http.py
M pywikibot/diff.py
M pywikibot/page.py
M pywikibot/site.py
M pywikibot/tools.py
6 files changed, 27 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/91/180691/1
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index ddfbbc9..21eb4a4 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1133,6 +1133,7 @@
"""
def __init__(self, **kwargs):
+ """Constructor."""
super(WikidataBot, self).__init__(**kwargs)
self.site = pywikibot.Site()
self.repo = self.site.data_repository()
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index ad2e2e8..444f3c7 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -166,6 +166,17 @@
def user_agent(site=None, format_string=None):
+ """
+ Generate the user agent string for a given site and format.
+
+ @param site: The site for which this user agent is intended. May be None.
+ @type site: BaseSite
+ @param format_string: The string to which the values will be added using
+ str.format. Is using config.user_agent_format when it is None.
+ @type format_string: basestring
+ @return: The formatted user agent
+ @rtype: unicode
+ """
values = USER_AGENT_PRODUCTS.copy()
# This is the Pywikibot revision; also map it to {version} at present.
diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index a93a90b..09fdfdf 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -158,6 +158,7 @@
return self.b[self.b_rng[0]:self.b_rng[1]]
def __str__(self):
+ """Return the diff as plain text."""
return u''.join(self.diff_plain_text)
def __repr__(self):
@@ -238,6 +239,7 @@
return blocks
def print_hunks(self):
+ """Print the headers and diff texts of all hunks to the output."""
for hunk in self.hunks:
pywikibot.output(hunk.header + hunk.diff_text)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index eba81a3..d96b8cb 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -576,6 +576,13 @@
return min(x.revid for x in history)
def previousRevision(self):
+ """
+ Return the revision id for the previous revision.
+
+ DEPRECATED: Use previous_revision_id instead.
+
+ @return: long
+ """
return self.previous_revision_id
def exists(self):
@@ -3276,6 +3283,7 @@
}
def getRedirectTarget(self):
+ """Return the redirect target for this page."""
target = super(ItemPage, self).getRedirectTarget()
cmodel = target.content_model
if cmodel != 'wikibase-item':
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 8f82568..8da3820 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -562,6 +562,9 @@
def username(self, sysop=False):
return self._username[sysop]
+ def tee(self):
+ return self._this_does_not_exist
+
def __getattr__(self, attr):
"""Delegate undefined methods calls to the Family object."""
if hasattr(self.__class__, attr):
diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index b12341a..d3112cb 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -90,6 +90,7 @@
self.version = tuple(components)
def __str__(self):
+ """Return version number with optional "wmf" suffix."""
vstring = '.'.join(str(v) for v in self.version)
if self.wmf_version:
vstring += 'wmf{0}'.format(self.wmf_version)
@@ -406,6 +407,7 @@
"""Return self when called."""
def __call__(self):
+ """Do nothing and just return itself."""
return self
--
To view, visit https://gerrit.wikimedia.org/r/180691
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5633447090ddfcf201ed38d7fea111a450c7177
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits