jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Check for invalid references tags
......................................................................
[bugfix] Check for invalid references tags
bug: T98115
Change-Id: I2fe3858fe036a0179c29c6746e1b10fa062cc00c
---
M scripts/noreferences.py
1 file changed, 16 insertions(+), 2 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 24f3669..1c22bbb 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -34,7 +34,7 @@
a list of affected articles
"""
#
-# (C) Pywikibot team, 2007-2014
+# (C) Pywikibot team, 2007-2015
#
# Distributed under the terms of the MIT license.
#
@@ -534,6 +534,20 @@
* Returns : The modified pagetext
"""
+ # Do we have a malformed <reference> tag which could be repaired?
+
+ # Repair two opening tags or a opening and an empty tag
+ pattern = re.compile(r'< *references *>(.*?)'
+ r'< */?\s*references */? *>', re.DOTALL)
+ if pattern.search(oldText):
+ pywikibot.output('Repairing references tag')
+ return re.sub(pattern, '<references>\1</references>', oldText)
+ # Repair single unclosed references tag
+ pattern = re.compile(r'< *references *>')
+ if pattern.search(oldText):
+ pywikibot.output('Repairing references tag')
+ return re.sub(pattern, '<references />', oldText)
+
# Is there an existing section where we can add the references tag?
for section in i18n.translate(self.site, referencesSections):
sectionR = re.compile(r'\r?\n=+ *%s *=+ *\r?\n' % section)
@@ -548,7 +562,7 @@
index = match.end()
else:
pywikibot.output(
- u'Adding references tag to existing %s section...\n'
+ 'Adding references tag to existing %s section...\n'
% section)
newText = (
oldText[:match.end()] + u'\n' +
--
To view, visit https://gerrit.wikimedia.org/r/208914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2fe3858fe036a0179c29c6746e1b10fa062cc00c
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Move unrelated parts of cosmetic_changes.py back to scripts folder
......................................................................
Move unrelated parts of cosmetic_changes.py back to scripts folder
These parts are only useful when the user wants to run as
a stand-alone script.
Change-Id: Iaccff3a58ebd6df07e5c2eaaccd04279a62bebe1
---
M pywikibot/cosmetic_changes.py
A scripts/cosmetic_changes.py
2 files changed, 143 insertions(+), 110 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 84e7db1..9c471fe 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -5,24 +5,7 @@
The changes are not supposed to change the look of the rendered wiki page.
-The following parameters are supported:
-
-¶ms;
-
--always Don't prompt you for each replacement. Warning (see below)
- has not to be confirmed. ATTENTION: Use this with care!
-
--async Put page on queue to be saved to wiki asynchronously.
-
--summary:XYZ Set the summary message text for the edit to XYZ, bypassing
- the predefined message texts with original and replacements
- inserted.
-
--ignore: Ignores if an error occured and skip either the page, or
- only that method, or only an instance of the problem in the
- page text. It can be set to 'page', 'method', or 'match'.
-
-&warning;
+If you wish to run this as an stand-alone script, use scripts/cosmetic_changes.py
For regular use, it is recommended to put this line into your user-config.py:
@@ -93,8 +76,7 @@
import pywikibot
-from pywikibot import config, i18n, textlib, pagegenerators
-from pywikibot.bot import ExistingPageBot, NoRedirectPageBot
+from pywikibot import config, textlib, pagegenerators
from pywikibot.page import url2unicode
from pywikibot.tools import deprecate_arg, first_lower, first_upper
from pywikibot.tools import MediaWikiVersion
@@ -958,93 +940,3 @@
"""Hyphenate ISBN numbers."""
return _reformat_ISBNs(
text, strict=False if self.ignore == CANCEL_MATCH else True)
-
-
-class CosmeticChangesBot(ExistingPageBot, NoRedirectPageBot):
-
- """Cosmetic changes bot."""
-
- def __init__(self, generator, **kwargs):
- self.availableOptions.update({
- 'async': False,
- 'comment': u'Robot: Cosmetic changes',
- 'ignore': CANCEL_ALL,
- })
- super(CosmeticChangesBot, self).__init__(**kwargs)
-
- self.generator = generator
-
- def treat_page(self):
- """Treat page with the cosmetic toolkit."""
- try:
- ccToolkit = CosmeticChangesToolkit.from_page(
- self.current_page, False, self.getOption('ignore'))
- changedText = ccToolkit.change(self.current_page.get())
- if changedText is not False:
- self.put_current(new_text=changedText,
- summary=self.getOption('comment'),
- async=self.getOption('async'))
- except pywikibot.LockedPage:
- pywikibot.output("Page %s is locked?!"
- % self.current_page.title(asLink=True))
- except pywikibot.EditConflict:
- pywikibot.output("An edit conflict has occured at %s."
- % self.current_page.title(asLink=True))
-
-
-def main(*args):
- """
- Process command line arguments and invoke bot.
-
- If args is an empty list, sys.argv is used.
-
- @param args: command line arguments
- @type args: list of unicode
- """
- options = {}
-
- # Process global args and prepare generator args parser
- local_args = pywikibot.handle_args(args)
- genFactory = pagegenerators.GeneratorFactory()
-
- for arg in local_args:
- if arg.startswith('-summary:'):
- options['comment'] = arg[len('-summary:'):]
- elif arg == '-always':
- options['always'] = True
- elif arg == '-async':
- options['async'] = True
- elif arg.startswith('-ignore:'):
- ignore_mode = arg[len('-ignore:'):].lower()
- if ignore_mode == 'method':
- options['ignore'] = CANCEL_METHOD
- elif ignore_mode == 'page':
- options['ignore'] = CANCEL_PAGE
- elif ignore_mode == 'match':
- options['ignore'] = CANCEL_MATCH
- else:
- raise ValueError('Unknown ignore mode "{0}"!'.format(ignore_mode))
- else:
- genFactory.handleArg(arg)
-
- site = pywikibot.Site()
-
- if 'comment' not in options or not options['comment']:
- # Load default summary message.
- options['comment'] = i18n.twtranslate(site,
- 'cosmetic_changes-standalone')
-
- gen = genFactory.getCombinedGenerator()
- if gen:
- if options.get('always') or pywikibot.input_yn(
- warning + '\nDo you really want to continue?',
- default=False, automatic_quit=False):
- site.login()
- preloadingGen = pagegenerators.PreloadingGenerator(gen)
- bot = CosmeticChangesBot(preloadingGen, **options)
- bot.run()
- else:
- pywikibot.showHelp()
-
-if __name__ == "__main__":
- main()
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
new file mode 100644
index 0000000..1ae4bf6
--- /dev/null
+++ b/scripts/cosmetic_changes.py
@@ -0,0 +1,141 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+This module can do slight modifications to tidy a wiki page's source code.
+
+The changes are not supposed to change the look of the rendered wiki page.
+
+The following parameters are supported:
+
+¶ms;
+
+-always Don't prompt you for each replacement. Warning (see below)
+ has not to be confirmed. ATTENTION: Use this with care!
+
+-async Put page on queue to be saved to wiki asynchronously.
+
+-summary:XYZ Set the summary message text for the edit to XYZ, bypassing
+ the predefined message texts with original and replacements
+ inserted.
+
+-ignore: Ignores if an error occured and either skips the page or
+ only that method. It can be set to 'page' or 'method'.
+
+&warning;
+
+For further information see pywikibot/cosmetic_changes.py
+"""
+#
+# (C) xqt, 2009-2013
+# (C) Pywikibot team, 2006-2015
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+#
+
+import pywikibot
+from pywikibot import i18n, pagegenerators, cosmetic_changes
+from pywikibot.bot import ExistingPageBot, NoRedirectPageBot
+
+
+warning = """
+ATTENTION: You can run this script as a stand-alone for testing purposes.
+However, the changes that are made are only minor, and other users
+might get angry if you fill the version histories and watchlists with such
+irrelevant changes. Some wikis prohibit stand-alone running."""
+
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+ '&warning;': warning,
+}
+
+
+class CosmeticChangesBot(ExistingPageBot, NoRedirectPageBot):
+
+ """Cosmetic changes bot."""
+
+ def __init__(self, generator, **kwargs):
+ self.availableOptions.update({
+ 'async': False,
+ 'summary': u'Robot: Cosmetic changes',
+ 'ignore': cosmetic_changes.CANCEL_ALL,
+ })
+ super(CosmeticChangesBot, self).__init__(**kwargs)
+
+ self.generator = generator
+
+ def treat_page(self):
+ """Treat page with the cosmetic toolkit."""
+ try:
+ ccToolkit = cosmetic_changes.CosmeticChangesToolkit.from_page(
+ self.current_page, False, self.getOption('ignore'))
+ changedText = ccToolkit.change(self.current_page.get())
+ if changedText is not False:
+ self.put_current(new_text=changedText,
+ summary=self.getOption('summary'),
+ async=self.getOption('async'))
+ except pywikibot.LockedPage:
+ pywikibot.output("Page %s is locked?!"
+ % self.current_page.title(asLink=True))
+ except pywikibot.EditConflict:
+ pywikibot.output("An edit conflict has occured at %s."
+ % self.current_page.title(asLink=True))
+
+
+def main(*args):
+ """
+ Process command line arguments and invoke bot.
+
+ If args is an empty list, sys.argv is used.
+
+ @param args: command line arguments
+ @type args: list of unicode
+ """
+ options = {}
+
+ # Process global args and prepare generator args parser
+ local_args = pywikibot.handle_args(args)
+ genFactory = pagegenerators.GeneratorFactory()
+
+ for arg in local_args:
+ if arg.startswith('-summary:'):
+ options['summary'] = arg[len('-summary:'):]
+ elif arg == '-always':
+ options['always'] = True
+ elif arg == '-async':
+ options['async'] = True
+ elif arg.startswith('-ignore:'):
+ ignore_mode = arg[len('-ignore:'):].lower()
+ if ignore_mode == 'method':
+ options['ignore'] = cosmetic_changes.CANCEL_METHOD
+ elif ignore_mode == 'page':
+ options['ignore'] = cosmetic_changes.CANCEL_PAGE
+ elif ignore_mode == 'match':
+ options['ignore'] = cosmetic_changes.CANCEL_MATCH
+ else:
+ raise ValueError('Unknown ignore mode "{0}"!'.format(ignore_mode))
+ else:
+ genFactory.handleArg(arg)
+
+ site = pywikibot.Site()
+
+ if not options.get('summary'):
+ # Load default summary message.
+ options['summary'] = i18n.twtranslate(site,
+ 'cosmetic_changes-standalone')
+
+ gen = genFactory.getCombinedGenerator()
+ if gen:
+ if options.get('always') or pywikibot.input_yn(
+ warning + '\nDo you really want to continue?',
+ default=False, automatic_quit=False):
+ site.login()
+ preloadingGen = pagegenerators.PreloadingGenerator(gen)
+ bot = CosmeticChangesBot(preloadingGen, **options)
+ bot.run()
+ else:
+ pywikibot.showHelp()
+
+if __name__ == "__main__":
+ main()
--
To view, visit https://gerrit.wikimedia.org/r/205843
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaccff3a58ebd6df07e5c2eaaccd04279a62bebe1
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2209
Status: Passed
Duration: 21 minutes and 3 seconds
Commit: f49ea26 (master)
Author: Mpaa
Message: ProofreadPage support in Site
When ProofreadPage extension is installed, API query proofreadinfo is
available.
Query returns Index and Page namespaces used by the extension and the
definition of the proofread quality levels used on the site.
This is preparation work in Site before introducing
ProofreadPage(Page).
Change-Id: I83cb7fc39b604672e5aaefec90af08b035028bf8
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/d064f91df8f1...f49ea26a…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/61852799
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications