jenkins-bot has submitted this change and it was merged.
Change subject: Make obsolete site object can be created
......................................................................
Make obsolete site object can be created
Per discussion, this patch makes it possible to create an obsolete
site object while the site object will be prevented from writing.
In other words, it will be a read-only site. Consequently, this
patch solves bug 55146. Note that although obsolete
sites now become readable, they will not be in site.languages().
In addition, this patch makes pagelanglinks() return only non-obsolete
sites by default to make old scripts still functional, but it adds a
parameter to suppress this functionality.
Tests adapted by Merlijn van Deen <valhallasw(a)gmail.com>
Bug: 61120
Bug: 55146
Change-Id: Ia12660ae2c16148ee7e13977155f1940fe560df1
Original-Change-Id: I3d6ef66c369da7f0b64b821d7d78454192601839
---
M pywikibot/page.py
M pywikibot/site.py
M tests/site_tests.py
3 files changed, 49 insertions(+), 15 deletions(-)
Approvals:
Nullzero: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index f95b39b..6c0178d 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -997,31 +997,40 @@
# ignore any links with invalid contents
continue
- def langlinks(self):
+ def langlinks(self, include_obsolete=False):
"""Return a list of all interlanguage Links on this page.
+
+ @param include_obsolete: if true, return even Link objects whose site
+ is obsolete
"""
# Data might have been preloaded
if not hasattr(self, '_langlinks'):
- self._langlinks = list(self.iterlanglinks())
+ self._langlinks = list(self.iterlanglinks(include_obsolete=True))
- return self._langlinks
+ if include_obsolete:
+ return self._langlinks
+ else:
+ return filter(lambda i: not i.site.obsolete, self._langlinks)
- def iterlanglinks(self, step=None, total=None):
+ def iterlanglinks(self, step=None, total=None, include_obsolete=False):
"""Iterate all interlanguage links on this page.
@param step: limit each API call to this number of pages
@param total: iterate no more than this number of pages in total
+ @param include_obsolete: if true, yield even Link object whose site
+ is obsolete
@return: a generator that yields Link objects.
"""
if hasattr(self, '_langlinks'):
- return iter(self._langlinks)
+ return iter(self.langlinks(include_obsolete=include_obsolete))
# XXX We might want to fill _langlinks when the Site
# method is called. If we do this, we'll have to think
# about what will happen if the generator is not completely
# iterated upon.
- return self.site.pagelanglinks(self, step=step, total=total)
+ return self.site.pagelanglinks(self, step=step, total=total,
+ include_obsolete=include_obsolete)
def data_item(self):
"""
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 0d1e92d..14b916a 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -129,15 +129,15 @@
else:
self.__family = fam
+ self.obsolete = False
# if we got an outdated language code, use the new one instead.
if self.__code in self.__family.obsolete:
if self.__family.obsolete[self.__code] is not None:
self.__code = self.__family.obsolete[self.__code]
else:
# no such language anymore
- raise NoSuchSite("Language %s in family %s is obsolete"
- % (self.__code, self.__family.name))
- if self.__code not in self.languages():
+ self.obsolete = True
+ elif self.__code not in self.languages():
if self.__family.name in list(self.__family.langs.keys()) and \
len(self.__family.langs) == 1:
oldcode = self.__code
@@ -707,10 +707,15 @@
@param right: the rights the logged in user should have
not supported yet and thus ignored.
@returns: a decorator to make sure the requirement is statisfied when
- the decorated function is called.
+ the decorated function is called. The function can be called
+ with as_group='sysop' to override the group set in the
+ decorator.
"""
def decorator(fn):
def callee(self, *args, **kwargs):
+ if self.obsolete:
+ raise NoSuchSite("Language %s in family %s is obsolete"
+ % (self.code, self.family.name))
grp = kwargs.pop('as_group', group)
if grp == 'user':
self.login(False)
@@ -1959,8 +1964,14 @@
# No such function in the API (this method isn't called anywhere)
raise NotImplementedError
- def pagelanglinks(self, page, step=None, total=None):
- """Iterate all interlanguage links on page, yielding Link objects."""
+ def pagelanglinks(self, page, step=None, total=None,
+ include_obsolete=False):
+ """Iterate all interlanguage links on page, yielding Link objects.
+
+ @param include_obsolete: if true, yield even Link objects whose
+ site is obsolete
+
+ """
lltitle = page.title(withSection=False)
llquery = self._generator(api.PropertyGenerator,
type_arg="langlinks",
@@ -1974,9 +1985,13 @@
if 'langlinks' not in pageitem:
continue
for linkdata in pageitem['langlinks']:
- yield pywikibot.Link.langlinkUnsafe(linkdata['lang'],
- linkdata['*'],
- source=self)
+ link = pywikibot.Link.langlinkUnsafe(linkdata['lang'],
+ linkdata['*'],
+ source=self)
+ if link.site.obsolete and not include_obsolete:
+ continue
+ else:
+ yield link
def page_extlinks(self, page, step=None, total=None):
"""Iterate all external links on page, yielding URL strings."""
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 79db3e2..10e5bdf 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1113,7 +1113,11 @@
# Implemented without setUpClass(cls) and global variables as objects
# were not completely disposed and recreated but retained 'memory'
def setUp(self):
+ self.code = 'test'
+ self.family = lambda: None
+ self.family.name = 'test'
self._logged_in_as = None
+ self.obsolete = False
def login(self, sysop):
# mock call
@@ -1158,6 +1162,12 @@
self.assertEqual(retval[1], kwargs)
self.assertEqual(self._logged_in_as, 'sysop')
+ def testObsoleteSite(self):
+ self.obsolete = True
+ args = (1, 2, 'a', 'b')
+ kwargs = {'i': 'j', 'k': 'l'}
+ self.assertRaises(pywikibot.NoSuchSite, self.call_this_user_req_function, args, kwargs)
+
if __name__ == '__main__':
try:
try:
--
To view, visit https://gerrit.wikimedia.org/r/120148
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia12660ae2c16148ee7e13977155f1940fe560df1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: More specific notice if api_number is None
......................................................................
More specific notice if api_number is None
If not -total option is given, api_number is None.
Print a more specific message while retrieving moved pages.
Change-Id: I4b72771a35824cce23d87eb7add3e82505dd2258
---
M scripts/redirect.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/redirect.py b/scripts/redirect.py
index d8451f0..1d85134 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -344,7 +344,8 @@
# self.offset hours ago
offset_time = start.strftime("%Y%m%d%H%M%S")
pywikibot.output(u'Retrieving %s moved pages via API...'
- % str(self.api_number))
+ % (str(self.api_number)
+ if self.api_number is not None else "all"))
move_gen = self.site.logevents(logtype="move", start=offset_time)
if self.api_number:
move_gen.set_maximum_items(self.api_number)
--
To view, visit https://gerrit.wikimedia.org/r/120215
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4b72771a35824cce23d87eb7add3e82505dd2258
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add test_link_in_section
......................................................................
Add test_link_in_section
test textlib.does_text_contain_section() for section headers with
links inside
Change-Id: Icdd03b9bb5340ed1cad2e8e6f11f65b52495c57d
---
M tests/pages/enwiki_help_editing.page
M tests/textlib_tests.py
2 files changed, 21 insertions(+), 6 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pages/enwiki_help_editing.page b/tests/pages/enwiki_help_editing.page
index 2ea663b..fa0f54d 100644
--- a/tests/pages/enwiki_help_editing.page
+++ b/tests/pages/enwiki_help_editing.page
@@ -54,7 +54,7 @@
===Adding references===
There is a [[Wikipedia:refToolbar 2.0|tool]] built into the top of the edit box that makes it easier to add and properly format references. The tool can use a single piece of data, such as the [[PMID]] or [[ISBN]], to fill in the rest of the details.
-==Wiki markup==
+==[[Wiki markup]]==
{{main|Help:Wiki markup}}
Wiki markup is the extra information (apart from the text which will be displayed) you enter in the edit window which tells the [[MediaWiki]] software how to display, categorize and process the article.
@@ -66,7 +66,7 @@
Make sure that you submit information which is relevant to Wikipedia's specific purpose, or your content might be deleted. You can always use the [[Help:Talk page|talk pages]] to ask questions or check to see if your idea will be accepted. Please make note of the license your contributions will be covered by.
* [[Wikipedia:Policies and guidelines|Policies and guidelines]]
-===Helpful tips===
+===[[:Help]]ful tips===
* [[Wikipedia:Contributing to Wikipedia|Contributing to Wikipedia]]
* [[Wikipedia:FAQ/Editing|FAQ/Editing]]
* [[Wikipedia:Cheatsheet|Cheatsheet]]
@@ -74,7 +74,7 @@
* [[Help:Protection|If the article is protected from editing]]
* [[Help:Page history|About page history]]
-===Naming and moving===
+=== Naming and moving ===
* [[Wikipedia:Moving a page|Moving a page to a new name]]
* [[Wikipedia:Article titles|Article titles]]
* [[Wikipedia:Namespace|Namespace]]
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 52aa8e2..06770d2 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# (C) Pywikipedia bot team, 2007
+# (C) Pywikibot team, 2007-2014
#
# Distributed under the terms of the MIT license.
#
@@ -55,10 +55,9 @@
self.assertEqual(func('{{a|b|c=d}}'), [('a', {u'1': 'b', 'c': 'd'})])
self.assertEqual(func('{{a|b={{c}}}}'), [('c', {}), (u'a', {u'b': u'{{c}}'})])
- @unittest.expectedFailure
def testSpacesInSection(self):
self.assertContains("enwiki_help_editing", u"Minor_edits")
- self.assertNotContains("enwiki_help_editing", u"Minor edits", "Incorrect, '#Minor edits' does not work")
+ self.assertNotContains("enwiki_help_editing", u"#Minor edits", "Incorrect, '#Minor edits' does not work")
self.assertNotContains("enwiki_help_editing", u"Minor Edits", "section hashes are case-sensitive")
self.assertNotContains("enwiki_help_editing", u"Minor_Edits", "section hashes are case-sensitive")
@@ -67,6 +66,22 @@
self.assertContains("enwiki_help_editing", u"Talk_.28discussion.29_pages", "As used in the TOC")
self.assertContains("enwiki_help_editing", u"Talk_(discussion)_pages", "Understood by mediawiki")
+ def test_spaces_outside_section(self):
+ self.assertContains("enwiki_help_editing", u"Naming and_moving")
+ self.assertContains("enwiki_help_editing", u" Naming and_moving ")
+ self.assertContains("enwiki_help_editing", u" Naming and_moving_")
+
+ def test_link_in_section(self):
+ # section is ==[[Wiki markup]]==
+ self.assertContains("enwiki_help_editing", u"[[Wiki markup]]", "Link as section header")
+ self.assertContains("enwiki_help_editing", u"[[:Wiki markup]]", "section header link with preleading colon")
+ self.assertNotContains("enwiki_help_editing", u"Wiki markup", "section header must be a link")
+ # section is ===[[:Help]]ful tips===
+ self.assertContains("enwiki_help_editing", u"[[Help]]ful tips", "Containing link")
+ self.assertContains("enwiki_help_editing", u"[[:Help]]ful tips", "Containing link with preleading colon")
+ self.assertNotContains("enwiki_help_editing", u"Helpful tips", "section header must contain a link")
+
+
if __name__ == '__main__':
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/120213
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icdd03b9bb5340ed1cad2e8e6f11f65b52495c57d
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: remove obsolete pywikibot.stopme() at the end of the script.
......................................................................
remove obsolete pywikibot.stopme() at the end of the script.
In core branch pywikibot.stopme() is called by atexit library.
The function is executed upon normal program termination. This
patch prohibits executing it twice.
Change-Id: Ieb1f20cf862a7bcc263d3ce5b0c7c0c578046c5a
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 6 insertions(+), 9 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index efd922b..04e4e41 100644
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -5,7 +5,7 @@
"""
#
# (C) xqt, 2009-2014
-# (C) Pywikipedia bot team, 2008-2013
+# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
@@ -99,11 +99,8 @@
if __name__ == '__main__':
- try:
- fam = []
- for arg in pywikibot.handleArgs():
- if arg in familiesDict.keys() and arg not in fam:
- fam.append(arg)
- update_family(fam)
- finally:
- pywikibot.stopme()
+ fam = []
+ for arg in pywikibot.handleArgs():
+ if arg in familiesDict.keys() and arg not in fam:
+ fam.append(arg)
+ update_family(fam)
--
To view, visit https://gerrit.wikimedia.org/r/120191
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb1f20cf862a7bcc263d3ce5b0c7c0c578046c5a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Alex S.H. Lin <alexsh(a)mail2000.com.tw>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: remove obsolete pywikibot.stopme() at the end of the script.
......................................................................
remove obsolete pywikibot.stopme() at the end of the script.
In core branch pywikibot.stopme() is called by atexit library.
The function is executed upon normal program termination. This
patch prohibits executing it twice.
Change-Id: I0489098e896f307e9e22c4ef45f1488b3cfda97a
---
M scripts/touch.py
1 file changed, 1 insertion(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py
index 59c21cb..86571b8 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -88,7 +88,4 @@
if __name__ == "__main__":
- try:
- main()
- finally:
- pywikibot.stopme()
+ main()
--
To view, visit https://gerrit.wikimedia.org/r/120194
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0489098e896f307e9e22c4ef45f1488b3cfda97a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Pyfisch <pyfisch(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: bugfixes, code improvements, i18n support
......................................................................
bugfixes, code improvements, i18n support
- fix TextEditor import
- -automatic option has been changed to mor common -always
- now we have i18n support from twn
- use generator instead of a list for all pages to be processed
- preload pages
- show page counter after processing, because we use a generator
- remove obsolete pywikibot.stopme() call
Change-Id: I8c983620e8d9a335b4fafa61e84936dc4c41f006
---
M scripts/spamremove.py
1 file changed, 73 insertions(+), 85 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/spamremove.py b/scripts/spamremove.py
index 8ee5397..2c6c50b 100755
--- a/scripts/spamremove.py
+++ b/scripts/spamremove.py
@@ -15,16 +15,16 @@
* not change the page in question
Command line options:
--automatic: Do not ask, but remove the lines automatically. Be very careful
- in using this option!
+-always Do not ask, but remove the lines automatically. Be very
+ careful in using this option!
--namespace: Filters the search to a given namespace. If this is specified
- multiple times it will search all given namespaces
+-namespace: Filters the search to a given namespace. If this is specified
+ multiple times it will search all given namespaces
"""
#
-# (C) Pywikipedia bot team, 2007-2010
+# (C) Pywikipedia bot team, 2007-2014
#
# Distributed under the terms of the MIT license.
#
@@ -33,35 +33,17 @@
#
import pywikibot
-from pywikibot import config
-from pywikibot import pagegenerators
-import editarticle
-import sys
+from pywikibot import pagegenerators, i18n
+from pywikibot.editor import TextEditor
def main():
- automatic = False
+ always = False
namespaces = []
- msg = {
- 'ar': u'إزالة الوصلات إلى موقع سبام %s',
- 'de': u'Entferne in Spam-Blacklist eingetragenen Weblink auf %s',
- 'en': u'Removing links to spamming site %s',
- 'es': u'Removiendo enlaces a sitio publicitario %s',
- 'fa': u'حذف پیوند به وبگاه هرزنگاری %s',
- 'he': u'מסיר קישורים לאתר ספאם %s',
- 'fr': u'Suppression du lien blacklisté %s',
- 'it': u'Rimuovo link contenuto nella Spam-Blacklist %s',
- 'ja': u'ロボットによる: 迷惑リンク削除 %s',
- 'nl': u'Links naar gespamde site: %s verwijderd',
- 'pt': u'Removendo links de spam do site %s',
- 'ta': u'எரிதமாக இணைக்கப்பட்ட %s இணையத்தளம் நீக்கப்பட்டது',
- 'vi': u'xóa các liên kết đến website spam %s',
- 'zh': u'機器人: 移除廣告黑名單連結 %s',
- }
spamSite = ''
for arg in pywikibot.handleArgs():
- if arg.startswith("-automatic"):
- automatic = True
+ if arg == "-always":
+ always = True
elif arg.startswith('-namespace:'):
try:
namespaces.append(int(arg[len('-namespace:'):]))
@@ -69,62 +51,68 @@
namespaces.append(arg[len('-namespace:'):])
else:
spamSite = arg
- if not automatic:
- config.put_throttle = 1
- if not spamSite:
- pywikibot.showHelp('spamremove')
- pywikibot.output(u"No spam site specified.")
- sys.exit()
- mysite = pywikibot.getSite()
- pages = list(set(mysite.exturlusage(spamSite)))
- if namespaces:
- pages = list(set(pagegenerators.NamespaceFilterPageGenerator(pages,
- namespaces)))
- if len(pages) == 0:
- pywikibot.output('No page found.')
- else:
- pywikibot.output('%d pages found.' % len(pages))
- for p in pages:
- text = p.get()
- if not spamSite in text:
- continue
- # Show the title of the page we're working on.
- # Highlight the title in purple.
- pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
- % p.title())
- lines = text.split('\n')
- newpage = []
- lastok = ""
- for line in lines:
- if spamSite in line:
- if lastok:
- pywikibot.output(lastok)
- pywikibot.output('\03{lightred}%s\03{default}' % line)
- lastok = None
- else:
- newpage.append(line)
- if line.strip():
- if lastok is None:
- pywikibot.output(line)
- lastok = line
- if automatic:
- answer = "y"
- else:
- answer = pywikibot.inputChoice(u'\nDelete the red lines?',
- ['yes', 'no', 'edit'],
- ['y', 'N', 'e'], 'n')
- if answer == "n":
- continue
- elif answer == "e":
- editor = editarticle.TextEditor()
- newtext = editor.edit(text, highlight=spamSite,
- jumpIndex=text.find(spamSite))
- else:
- newtext = "\n".join(newpage)
- if newtext != text:
- p.put(newtext, pywikibot.translate(mysite, msg) % spamSite)
-try:
+ if not spamSite:
+ pywikibot.showHelp()
+ pywikibot.output(u"No spam site specified.")
+ return
+
+ mysite = pywikibot.getSite()
+ pages = mysite.exturlusage(spamSite)
+ if namespaces:
+ pages = pagegenerators.NamespaceFilterPageGenerator(pages, namespaces)
+ pages = pagegenerators.PreloadingGenerator(pages)
+
+ summary = i18n.twtranslate(mysite, 'spamremove-remove',
+ {'url': spamSite})
+ for i, p in enumerate(pages, 1):
+ text = p.text
+ if not spamSite in text:
+ continue
+ # Show the title of the page we're working on.
+ # Highlight the title in purple.
+ pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
+ % p.title())
+ lines = text.split('\n')
+ newpage = []
+ lastok = ""
+ for line in lines:
+ if spamSite in line:
+ if lastok:
+ pywikibot.output(lastok)
+ pywikibot.output('\03{lightred}%s\03{default}' % line)
+ lastok = None
+ else:
+ newpage.append(line)
+ if line.strip():
+ if lastok is None:
+ pywikibot.output(line)
+ lastok = line
+ if always:
+ answer = "y"
+ else:
+ answer = pywikibot.inputChoice(u'\nDelete the red lines?',
+ ['yes', 'no', 'edit'],
+ ['y', 'N', 'e'], 'n')
+ if answer == "n":
+ continue
+ elif answer == "e":
+ editor = TextEditor()
+ newtext = editor.edit(text, highlight=spamSite,
+ jumpIndex=text.find(spamSite))
+ else:
+ newtext = "\n".join(newpage)
+ if newtext != text:
+ p.text = newtext
+ p.save(summary)
+ else:
+ if "i" not in locals():
+ pywikibot.output('No page found.')
+ elif i == 1:
+ pywikibot.output('1 pages done.')
+ else:
+ pywikibot.output('%d pages done.' % i)
+
+
+if __name__ == '__main__':
main()
-finally:
- pywikibot.stopme()
--
To view, visit https://gerrit.wikimedia.org/r/120203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8c983620e8d9a335b4fafa61e84936dc4c41f006
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>