jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] page/textlib: add remaining docstrings
......................................................................
[IMPROV] page/textlib: add remaining docstrings
Only two docstrings were missing from the page module with PEP257 0.6.0 to
comply with the mandatory tox job. And the textlib module was missing only one.
Change-Id: Ied7846896301e2acb587e7414aebb4b26438a69c
---
M pywikibot/page.py
M pywikibot/textlib.py
M tox.ini
3 files changed, 35 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 73c030f..1f94132 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4138,6 +4138,11 @@
'hash': data['hash']})
def toJSON(self):
+ """
+ Create dict suitable for the MediaWiki API.
+
+ @rtype: dict
+ """
data = {
'mainsnak': {
'snaktype': self.snaktype,
@@ -4524,6 +4529,17 @@
@property
def sha1(self):
+ """
+ Return and cache SHA1 checksum of the text.
+
+ @return: if the SHA1 checksum is cached it'll be returned which is the
+ case when it was requested from the API. Otherwise it'll use the
+ revision's text to calculate the checksum (encoding it using UTF8
+ first). That calculated checksum will be cached too and returned on
+ future calls. If the text is None (not queried) it will just return
+ None and does not cache anything.
+ @rtype: str or None
+ """
if self._sha1 is None:
if self.text is None:
# No text? No sha1 then.
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 1612436..a0b4d99 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -429,9 +429,23 @@
def expandmarker(text, marker='', separator=''):
- # set to remove any number of separator occurrences plus arbitrary
- # whitespace before, after, and between them,
- # by allowing to include them into marker.
+ """
+ Return a marker expanded whitespace and the separator.
+
+ It searches for the first occurrence of the marker and gets the combination
+ of the separator and whitespace directly before it.
+
+ @param text: the text which will be searched.
+ @type text: str
+ @param marker: the marker to be searched.
+ @type marker: str
+ @param separator: the separator string allowed before the marker. If empty
+ it won't include whitespace too.
+ @type separator: str
+ @return: the marker with the separator and whitespace from the text in front
+ of it. It'll be just the marker if the separator is empty.
+ @rtype: str
+ """
if separator:
firstinmarker = text.find(marker)
firstinseparator = firstinmarker
diff --git a/tox.ini b/tox.ini
index ae7e9c2..d85d20b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -56,8 +56,10 @@
pywikibot/fixes.py \
pywikibot/i18n.py \
pywikibot/login.py \
+ pywikibot/page.py \
pywikibot/pagegenerators.py \
pywikibot/plural.py \
+ pywikibot/textlib.py \
pywikibot/throttle.py \
pywikibot/tools/__init__.py \
pywikibot/tools/ip.py \
--
To view, visit
https://gerrit.wikimedia.org/r/226306
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied7846896301e2acb587e7414aebb4b26438a69c
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>