Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #4374
Status: Passed
Duration: 46 minutes and 47 seconds
Commit: 814f43c (master)
Author: dalba
Message: noreferences.py: Make sure there is an empty line before the references section
Add param info to the docstring of createReferenceSection.
Add another newline before the ref_section (this is to create an empty line).
Make sure there won't be any extra newlines by rstripping the oldText[:index].
Bug: T179255
Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/e639ff117579...814f43c3…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/294698703?utm_source=…
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/387160 )
Change subject: noreferences.py: Make sure there is an empty line before the references section
......................................................................
noreferences.py: Make sure there is an empty line before the references section
Add param info to the docstring of createReferenceSection.
Add another newline before the ref_section (this is to create an empty line).
Make sure there won't be any extra newlines by rstripping the oldText[:index].
Bug: T179255
Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
---
M scripts/noreferences.py
1 file changed, 18 insertions(+), 8 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 504c638..9846df2 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -635,16 +635,26 @@
return self.createReferenceSection(oldText, index)
def createReferenceSection(self, oldText, index, ident='=='):
- """Create a reference section and insert it into the given text."""
+ """Create a reference section and insert it into the given text.
+
+ @param oldText: page text that is going to be be amended
+ @type oldText: str
+ @param index: the index of oldText where the reference section should
+ be inserted at
+ @type index: int
+ @param ident: symbols to be inserted before and after reference section
+ title
+ @type ident: str
+ @return: the amended page text with reference section added
+ @rtype: str
+ """
if self.site.code in noTitleRequired:
- newSection = u'\n%s\n' % (self.referencesText)
+ ref_section = '\n\n%s\n' % self.referencesText
else:
- newSection = u'\n%s %s %s\n%s\n' % (ident,
- i18n.translate(
- self.site,
- referencesSections)[0],
- ident, self.referencesText)
- return oldText[:index] + newSection + oldText[index:]
+ ref_section = '\n\n{ident} {title} {ident}\n{text}\n'.format(
+ title=i18n.translate(self.site, referencesSections)[0],
+ ident=ident, text=self.referencesText)
+ return oldText[:index].rstrip() + ref_section + oldText[index:]
def run(self):
"""Run the bot."""
--
To view, visit https://gerrit.wikimedia.org/r/387160
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/385773 )
Change subject: [bugfix] Use grnfilterredir for random pages
......................................................................
[bugfix] Use grnfilterredir for random pages
Bug: T178732
Change-Id: I0763cf99fd113cd25a0048d8a760b16fc4828346
---
M pywikibot/site.py
M tests/site_tests.py
2 files changed, 28 insertions(+), 5 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ac20cd0..7b09c7f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4924,7 +4924,7 @@
'users', ususers=usernames, site=self, usprop=usprop)
return usgen
- @deprecated("Site.randompages()")
+ @deprecated('Site.randompages(total=1)')
def randompage(self, redirect=False):
"""
DEPRECATED.
@@ -4934,7 +4934,7 @@
"""
return self.randompages(total=1, redirects=redirect)
- @deprecated("Site.randompages()")
+ @deprecated("Site.randompages(total=1, redirects=True)")
def randomredirectpage(self):
"""
DEPRECATED: Use Site.randompages() instead.
@@ -4956,17 +4956,34 @@
@type namespaces: iterable of basestring or Namespace key,
or a single instance of those types. May be a '|' separated
list of namespace identifiers.
- @param redirects: if True, include only redirect pages in results
- (default: include only non-redirects)
+ @param redirects: if True, include only redirect pages in results,
+ False does not include redirects and None (MW 1.26+) include both
+ types. (default: False)
+ @type redirects: bool or None
@param content: if True, load the current content of each iterated page
(default False)
@raises KeyError: a namespace identifier was not resolved
@raises TypeError: a namespace identifier has an inappropriate
type such as NoneType or bool
+ @raises AssertError: unsupported redirects parameter
"""
+ mapping = {False: None, True: 'redirects', None: 'all'}
+ assert redirects in mapping
+ redirects = mapping[redirects]
+ params = {}
+ if redirects is not None:
+ if MediaWikiVersion(self.version()) < MediaWikiVersion('1.26'):
+ if redirects == 'all':
+ warn("parameter redirects=None to retrieve 'all' random"
+ 'page types is not supported by mw version {0}. '
+ 'Using default.'.format(self.version()),
+ UserWarning)
+ params['grnredirect'] = redirects == 'redirects'
+ else:
+ params['grnfilterredir'] = redirects
rngen = self._generator(api.PageGenerator, type_arg="random",
namespaces=namespaces, total=total,
- g_content=content, grnredirect=redirects)
+ g_content=content, **params)
return rngen
# Catalog of editpage error codes, for use in generating messages.
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 1b45692..3ef9079 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -2006,6 +2006,12 @@
self.assertIsInstance(rndpage, pywikibot.Page)
self.assertTrue(rndpage.isRedirectPage())
+ def test_all(self):
+ """Test site.randompages() with both types."""
+ mysite = self.get_site()
+ for rndpage in mysite.randompages(total=5, redirects=None):
+ self.assertIsInstance(rndpage, pywikibot.Page)
+
def test_namespaces(self):
"""Test site.randompages() with namespaces."""
mysite = self.get_site()
--
To view, visit https://gerrit.wikimedia.org/r/385773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0763cf99fd113cd25a0048d8a760b16fc4828346
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>