jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/434266 )
Change subject: [IMPR] use setup/teardown for scripts
......................................................................
[IMPR] use setup/teardown for scripts
instead of overwriting run method use new setup or teardown method
Change-Id: I93e22d325c1809e92dbdadbbe2ab1baf0fe9f7a3
---
M scripts/category.py
M scripts/lonelypages.py
2 files changed, 12 insertions(+), 12 deletions(-)
Approvals:
JJMC89: Looks good to me, but someone else must approve
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index e95594f..09faef2 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -1108,12 +1108,11 @@
self.move_to_category(member, original_cat,
subcatlist[choice[1]])
- def run(self):
- """Start bot."""
- super(CategoryTidyRobot, self).run()
+ def teardown(self):
+ """Cleanups after run operation."""
if not self._treat_counter:
- pywikibot.output('There are no pages or files in category %s'
- % self.catTitle)
+ pywikibot.output('There are no pages or files in category {}'
+ .format(self.catTitle))
def treat(self, page):
"""Process page."""
diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py
index ca9f9c2..8f4d2d1 100755
--- a/scripts/lonelypages.py
+++ b/scripts/lonelypages.py
@@ -34,7 +34,7 @@
#
# (C) Pietrodn, it.wiki 2006-2007
# (C) Filnik, it.wiki 2007
-# (C) Pywikibot team, 2008-2017
+# (C) Pywikibot team, 2008-2018
#
# Distributed under the terms of the MIT license.
#
@@ -168,14 +168,15 @@
return getenable == 'enable'
return True
- def run(self):
- """Run the bot."""
- # If the enable page is set to disable, turn off the bot
- # (useful when the bot is run on a server)
+ def setup(self):
+ """Setup the bot.
+
+ If the enable page is set to disable, set an empty generator which
+ turns off the bot (useful when the bot is run on a server).
+ """
if not self.enable_page():
pywikibot.output('The bot is disabled')
- return
- super(LonelyPagesBot, self).run()
+ self.generator = ()
def treat(self, page):
"""Check if page is applicable and not marked and add template then."""
--
To view, visit https://gerrit.wikimedia.org/r/434266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I93e22d325c1809e92dbdadbbe2ab1baf0fe9f7a3
Gerrit-Change-Number: 434266
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(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/434515 )
Change subject: page.py: Fix the rtype of Link.site
......................................................................
page.py: Fix the rtype of Link.site
Also add rtype to Page.site.
Change-Id: I61f5ddc1f27bbc12a72426d2b81eaf7cb4c25f3b
---
M pywikibot/page.py
1 file changed, 5 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 570cb6a..73720da 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -211,7 +211,10 @@
@property
def site(self):
- """Return the Site object for the wiki on which this Page resides."""
+ """Return the Site object for the wiki on which this Page resides.
+
+ @rtype: pywikibot.Site
+ """
return self._link.site
def version(self):
@@ -5673,7 +5676,7 @@
"""
Return the site of the link.
- @rtype: unicode
+ @rtype: pywikibot.Site
"""
if not hasattr(self, "_site"):
self.parse()
--
To view, visit https://gerrit.wikimedia.org/r/434515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I61f5ddc1f27bbc12a72426d2b81eaf7cb4c25f3b
Gerrit-Change-Number: 434515
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(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/434464 )
Change subject: setup.py: Flatten the extra_deps.items() before adding them to test_deps
......................................................................
setup.py: Flatten the extra_deps.items() before adding them to test_deps
extra_deps.items() is a list of lists. Although setuptools can handle
that, but statements like test_deps.remove('oursql') will not work.
Bug: T195287
Change-Id: I0265a8bd694323f99d37bc5faa78a502f3148e46
---
M setup.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 2f7b9cc..f07c7a5 100644
--- a/setup.py
+++ b/setup.py
@@ -167,7 +167,7 @@
# Add all dependencies as test dependencies,
# so all scripts can be compiled for script_tests, etc.
if 'PYSETUP_TEST_EXTRAS' in os.environ:
- test_deps += [v for k, v in extra_deps.items() if k != 'flake8']
+ test_deps += [i for k, v in extra_deps.items() if k != 'flake8' for i in v]
if 'oursql' in test_deps and os.name == 'nt':
test_deps.remove('oursql') # depends on Cython
--
To view, visit https://gerrit.wikimedia.org/r/434464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0265a8bd694323f99d37bc5faa78a502f3148e46
Gerrit-Change-Number: 434464
Gerrit-PatchSet: 7
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(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/433916 )
Change subject: [IMPR] Merge duplicate regexes dicts
......................................................................
[IMPR] Merge duplicate regexes dicts
Bug: T195026
Change-Id: I0c75e66598c502b4f6f5df737ebc8a770db6e966
---
M pywikibot/textlib.py
1 file changed, 27 insertions(+), 26 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 9ba2b5f..5f0f411 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -305,7 +305,8 @@
# which may not yet have a site specific re compiled.
if exc in _regex_cache:
if type(_regex_cache[exc]) is tuple:
- if not site:
+ if not site and exc in ('interwiki', 'property', 'invoke',
+ 'category', 'file'):
issue_deprecation_warning(
'site=None', 'a valid site', 3)
site = pywikibot.Site()
@@ -452,37 +453,37 @@
return text
-def removeDisabledParts(text, tags=['*'], include=[]):
+def removeDisabledParts(text, tags=None, include=[], site=None):
"""
Return text without portions where wiki markup is disabled.
- Parts that can/will be removed are --
+ Parts that will be removed by default are
* HTML comments
* nowiki tags
* pre tags
* includeonly tags
+ * source and syntaxhighlight tags
- The exact set of parts which should be removed can be passed as the
- 'tags' parameter, which defaults to all.
- Or, in alternative, default parts that shall not be removed can be
- specified in the 'include' param.
+ @param tags: The exact set of parts which should be removed using
+ keywords from textlib._get_regexes().
+ @type tags: list, set, tuple or None
+ @param include: Or, in alternative, default parts that shall not
+ be removed.
+ @type include: list, set or tuple
+
+ @param site: Site to be used for site-dependent regexes. Default
+ disabled parts listed above do not need it.
+ @type site: pywikibot.Site
+
+ @return: text stripped from disabled parts.
+ @rtype: str
"""
- regexes = {
- 'comments': r'<!--.*?-->',
- 'includeonly': r'<includeonly\s*>.*?</includeonly\s*>',
- 'nowiki': r'<nowiki\s*>.*?</nowiki\s*>',
- 'pre': r'<pre\s*>.*?</pre\s*>',
- 'source': r'<source[ >].*?</source\s*>',
- 'syntaxhighlight': r'<syntaxhighlight[ >].*?</syntaxhighlight\s*>',
- }
- if '*' in tags:
- tags = list(regexes.keys())
- # add alias
+ if not tags:
+ tags = ('comment', 'includeonly', 'nowiki', 'pre', 'source')
tags = set(tags) - set(include)
- if 'source' in tags:
- tags.add('syntaxhighlight')
- toRemoveR = re.compile('|'.join([regexes[tag] for tag in tags]),
+ regexes = _get_regexes(tags, site)
+ toRemoveR = re.compile('|'.join(x.pattern for x in regexes),
re.IGNORECASE | re.DOTALL)
return toRemoveR.sub('', text)
@@ -525,7 +526,7 @@
self.textdata += u"</%s>" % tag
-def isDisabled(text, index, tags=['*']):
+def isDisabled(text, index, tags=None):
"""
Return True if text[index] is disabled, e.g. by a comment or nowiki tags.
@@ -861,10 +862,10 @@
result = {}
# Ignore interwiki links within nowiki tags, includeonly tags, pre tags,
# and HTML comments
- tags = ['comments', 'nowiki', 'pre', 'source']
- if not template_subpage:
- tags += ['includeonly']
- text = removeDisabledParts(text, tags)
+ include = []
+ if template_subpage:
+ include = ['includeonly']
+ text = removeDisabledParts(text, include=include)
# This regular expression will find every link that is possibly an
# interwiki link.
--
To view, visit https://gerrit.wikimedia.org/r/433916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c75e66598c502b4f6f5df737ebc8a770db6e966
Gerrit-Change-Number: 433916
Gerrit-PatchSet: 8
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(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/434347 )
Change subject: setup.py: Don't install flake8 dependencies if PYSETUP_TEST_EXTRAS is set
......................................................................
setup.py: Don't install flake8 dependencies if PYSETUP_TEST_EXTRAS is set
Test suites do not require flake8.
After ca862f1809953bd5c15ed65d198e0508202e1c3f, some travis jobs are
failing due the version conflicts within flake8 dependencies.
Change-Id: I9a4ebf3ea2c7ca85ca77a30109a272936078aa61
---
M setup.py
1 file changed, 1 insertion(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 5572b63..2f7b9cc 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,6 @@
#
from __future__ import absolute_import, print_function, unicode_literals
-import itertools
import os
import sys
@@ -168,7 +167,7 @@
# Add all dependencies as test dependencies,
# so all scripts can be compiled for script_tests, etc.
if 'PYSETUP_TEST_EXTRAS' in os.environ:
- test_deps += list(itertools.chain(*(extra_deps.values())))
+ test_deps += [v for k, v in extra_deps.items() if k != 'flake8']
if 'oursql' in test_deps and os.name == 'nt':
test_deps.remove('oursql') # depends on Cython
--
To view, visit https://gerrit.wikimedia.org/r/434347
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9a4ebf3ea2c7ca85ca77a30109a272936078aa61
Gerrit-Change-Number: 434347
Gerrit-PatchSet: 5
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>