jenkins-bot has submitted this change and it was merged.
Change subject: use all pagegenerators options for protect.py
......................................................................
use all pagegenerators options for protect.py
- remove "nosubcat" option which was never implemented
- include revision: 0b888f24b532d54ee93574632b34c162fbe77ba0
made by Merlijn van Deen:
mysite was not defined. pywikibot.handleArgs is guaranteed to
return a list (as opposed to a generator) after parsing all
global arguments (such as -lang and -family). This means it's
safe to call pywikibot.getSite immediately after handleArgs,
but before handling local arguments.
- pageName is extracted from command option handled
by pagegenerators if availlable. Otherwise we ask for the
message.
- -images option is deprecated. -imageused from pagegenerators is
used. We just append the right option command to the option list
- docu replacement from pagegenerators
Change-Id: I6e2b6b85670a28e24c50f6da9cb6b3db236f78b5
---
M scripts/protect.py
1 file changed, 76 insertions(+), 118 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/protect.py b/scripts/protect.py
index deaae24..7ed203f 100644
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -3,21 +3,21 @@
This script can be used to protect and unprotect pages en masse.
Of course, you will need an admin account on the relevant wiki.
-Syntax: python protect.py OPTION...
-Command line options:
+These command line parameters can be used to specify which pages to work on:
--page: Protect specified page
--cat: Protect all pages in the given category.
--nosubcats: Don't protect pages in the subcategories.
--links: Protect all pages linked from a given page.
--file: Protect all pages listed in a text file.
--ref: Protect all pages referring from a given page.
--images: Protect all images used on a given page.
--always: Don't prompt to protect pages, just do it.
--summary: Supply a custom edit summary.
--unprotect: Actually unprotect pages instead of protecting
+¶ms;
+
+Furthermore, the following command line parameters are supported:
+
+-always: Don't prompt to protect pages, just do it.
+
+-summary: Supply a custom edit summary.
+
+-unprotect: Actually unprotect pages instead of protecting
+
-edit:PROTECTION_LEVEL Set edit protection level to PROTECTION_LEVEL
+
-move:PROTECTION_LEVEL Set move protection level to PROTECTION_LEVEL
## Without support ##
@@ -26,6 +26,8 @@
Values for PROTECTION_LEVEL are: sysop, autoconfirmed, none.
If an operation parameter (edit, move or create) is not specified, default
protection level is 'sysop' (or 'none' if -unprotect).
+
+Usage: python protect.py <OPTIONS>
Examples:
@@ -40,7 +42,7 @@
# Written by http://it.wikisource.org/wiki/Utente:Qualc1
# Created by modifying delete.py
#
-# (C) Pywikibot team, 2008-2013
+# (c) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
@@ -51,11 +53,15 @@
from pywikibot import i18n
from pywikibot import pagegenerators
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+}
+
class ProtectionRobot:
- """
- This robot allows protection of pages en masse.
- """
+ """ This robot allows protection of pages en masse. """
def __init__(self, generator, summary, always=False, unprotect=False,
edit='sysop', move='sysop', create='sysop'):
@@ -75,20 +81,21 @@
self.move = move
def run(self):
+ """ Starts the robot's action.
+ Loop through everything in the page generator and (un)protect it.
+
"""
- Starts the robot's action.
- """
- #Loop through everything in the page generator and (un)protect it.
for page in self.generator:
pywikibot.output(u'Processing page %s' % page.title())
page.protect(unprotect=self.unprotect, reason=self.summary,
- prompt=self.prompt, edit=self.edit,
- move=self.move)
+ prompt=self.prompt, edit=self.edit, move=self.move)
-# Asks a valid protection level for "operation".
-# Returns the protection level chosen by user.
def choiceProtectionLevel(operation, default):
+ """ Asks a valid protection level for "operation".
+ Returns the protection level chosen by user.
+
+ """
default = default[0]
firstChar = map(lambda level: level[0], protectionLevels)
choiceChar = pywikibot.inputChoice('Choice a protection level to %s:'
@@ -100,74 +107,38 @@
return level
-def main():
+def main(*args):
global protectionLevels
protectionLevels = ['sysop', 'autoconfirmed', 'none']
+ # This factory is responsible for processing command line arguments
+ # that are also used by other scripts and that determine on which pages
+ # to work on.
+ genFactory = pagegenerators.GeneratorFactory()
pageName = ''
- summary = ''
+ summary = None
always = False
- doSinglePage = False
- doCategory = False
- protectSubcategories = True
- doRef = False
- doLinks = False
- doImages = False
- fileName = ''
- gen = None
+ generator = None
edit = ''
move = ''
defaultProtection = 'sysop'
# read command line parameters
- for arg in pywikibot.handleArgs():
+ localargs = pywikibot.handleArgs()
+ mysite = pywikibot.getSite()
+
+ for arg in pywikibot.handleArgs(*args):
if arg == '-always':
always = True
- elif arg.startswith('-file'):
- if len(arg) == len('-file'):
- fileName = pywikibot.input(
- u'Enter name of file to protect pages from:')
- else:
- fileName = arg[len('-file:'):]
elif arg.startswith('-summary'):
if len(arg) == len('-summary'):
- summary = pywikibot.input(
- u'Enter a reason for the protection:')
+ summary = pywikibot.input(u'Enter a reason for the protection:')
else:
summary = arg[len('-summary:'):]
- elif arg.startswith('-cat'):
- doCategory = True
- if len(arg) == len('-cat'):
- pageName = pywikibot.input(
- u'Enter the category to protect from:')
- else:
- pageName = arg[len('-cat:'):]
- elif arg.startswith('-nosubcats'):
- protectSubcategories = False
- elif arg.startswith('-links'):
- doLinks = True
- if len(arg) == len('-links'):
- pageName = pywikibot.input(u'Enter the page to protect from:')
- else:
- pageName = arg[len('-links:'):]
- elif arg.startswith('-ref'):
- doRef = True
- if len(arg) == len('-ref'):
- pageName = pywikibot.input(u'Enter the page to protect from:')
- else:
- pageName = arg[len('-ref:'):]
- elif arg.startswith('-page'):
- doSinglePage = True
- if len(arg) == len('-page'):
- pageName = pywikibot.input(u'Enter the page to protect:')
- else:
- pageName = arg[len('-page:'):]
elif arg.startswith('-images'):
- doImages = True
- if len(arg) == len('-images'):
- pageName = pywikibot.input(u'Enter the page with the images to protect:')
- else:
- pageName = arg[len('-images:'):]
+ pywikibot.output('\n\03{lightred}-image option is deprecated. '
+ 'Please use -imagelinks instead.\03{default}\n')
+ localargs.append('-imagelinks' + arg[7:])
elif arg.startswith('-unprotect'):
defaultProtection = 'none'
elif arg.startswith('-edit'):
@@ -182,58 +153,45 @@
create = arg[len('-create:'):]
if create not in protectionLevels:
create = choiceProtectionLevel('create', defaultProtection)
+ else:
+ genFactory.handleArg(arg)
+ found = arg.find(':') + 1
+ if found:
+ pageName = arg[found:]
- mysite = pywikibot.getSite()
+ if not summary:
+ if pageName:
+ if arg.startswith('cat') or arg.startswith('subcats'):
+ summary = i18n.twtranslate(mysite, 'protect-category',
+ {'cat': pageName})
+ elif arg.startswith('links'):
+ summary = i18n.twtranslate(mysite, 'protect-links',
+ {'page': pageName})
+ elif arg.startswith('ref'):
+ summary = i18n.twtranslate(mysite, 'protect-ref',
+ {'page': pageName})
+ elif arg.startswith('imageused'):
+ summary = i18n.twtranslate(mysite, 'protect-images',
+ {'page': pageName})
+ elif arg.startswith('file'):
+ summary = i18n.twtranslate(mysite, 'protect-simple')
- if doSinglePage:
- if not summary:
- summary = pywikibot.input(u'Enter a reason for the protection:')
- page = pywikibot.Page(mysite, pageName)
- gen = iter([page])
- elif doCategory:
- if not summary:
- summary = i18n.twtranslate(mysite, 'protect-category',
- {'cat': pageName})
- ns = mysite.category_namespace()
- categoryPage = pywikibot.Category(mysite, ns + ':' + pageName)
- gen = pagegenerators.CategorizedPageGenerator(
- categoryPage, recurse=protectSubcategories)
- elif doLinks:
- if not summary:
- summary = i18n.twtranslate(mysite, 'protect-links',
- {'page': pageName})
- linksPage = pywikibot.Page(mysite, pageName)
- gen = pagegenerators.LinkedPageGenerator(linksPage)
- elif doRef:
- if not summary:
- summary = i18n.twtranslate(mysite, 'protect-ref',
- {'page': pageName})
- refPage = pywikibot.Page(mysite, pageName)
- gen = pagegenerators.ReferringPageGenerator(refPage)
- elif fileName:
- if not summary:
- summary = i18n.twtranslate(mysite, 'protect-simple')
- gen = pagegenerators.TextfilePageGenerator(fileName)
- elif doImages:
- if not summary:
- summary = i18n.twtranslate(mysite, 'protect-images',
- {'page': pageName})
- gen = pagegenerators.ImagesPageGenerator(pywikibot.Page(mysite,
- pageName))
-
- if gen:
- pywikibot.setAction(summary)
- # We are just protecting pages, so we have no need of using a preloading
- # page generator
- # to actually get the text of those pages.
+ generator = genFactory.getCombinedGenerator()
+ # We are just protecting pages, so we have no need of using a preloading
+ # page generator to actually get the text of those pages.
+ if generator:
+ if summary is None:
+ summary = pywikibot.input(u'Enter a reason for the %sprotection:'
+ % ['', 'un'][protectionLevels == 'none'])
if not edit:
edit = defaultProtection
if not move:
move = defaultProtection
- bot = ProtectionRobot(gen, summary, always, edit=edit, move=move)
+ bot = ProtectionRobot(generator, summary, always, edit=edit, move=move)
bot.run()
else:
- pywikibot.showHelp(u'protect')
+ # Show help text from the top of this file
+ pywikibot.showHelp()
if __name__ == "__main__":
--
To view, visit https://gerrit.wikimedia.org/r/104198
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6e2b6b85670a28e24c50f6da9cb6b3db236f78b5
Gerrit-PatchSet: 6
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Update translatewiki.net ("i18n") family
......................................................................
Update translatewiki.net ("i18n") family
With the old version, I get a login error (!).
The wiki is also now using HSTS, but that doesn't seem to be the culprit.
Change-Id: I76701c1fb2aba079ae6737e4ce6ff7bb9f8984b6
---
M pywikibot/families/i18n_family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/i18n_family.py b/pywikibot/families/i18n_family.py
index fc7a1af..f1dea70 100644
--- a/pywikibot/families/i18n_family.py
+++ b/pywikibot/families/i18n_family.py
@@ -16,4 +16,4 @@
}
def version(self, code):
- return "1.20alpha"
+ return "1.23alpha"
--
To view, visit https://gerrit.wikimedia.org/r/112810
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I76701c1fb2aba079ae6737e4ce6ff7bb9f8984b6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Nemo bis <federicoleva(a)tiscali.it>
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: Make language of messages depend on site
......................................................................
Make language of messages depend on site
Language of messages queried from allmessages depends on bot's setting
(see bug: 61119). However, APISite.mediawiki_messages() depends on
site object. This patch therefore makes mediawiki_messages()
retrieve the correct language.
Change-Id: I9c5a0b5b549822731247374140e44a79f09f33a5
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index bdf6618..3d85c6b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1011,6 +1011,7 @@
site=self,
meta="allmessages",
ammessages='|'.join(keys),
+ amlang=self.lang,
)
# Return all messages
--
To view, visit https://gerrit.wikimedia.org/r/112604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c5a0b5b549822731247374140e44a79f09f33a5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Nullzero <nullzero.free(a)gmail.com>
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: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Pyfisch <pyfisch(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: Let us pass arguments to flake8 in tox env
......................................................................
Let us pass arguments to flake8 in tox env
Tox variable '{posargs}' contains arguments passed to tox with something
like:
tox -- <my arguments there>
By adding '{posargs}' to the flake8 command of the flake8 env, one can
pass extra arguments to flake8, for example:
tox -eflake8 -- --statistics --show-source
Change-Id: I7d75c282284cc7bba699fa01674efd328f0c0a25
---
M tox.ini
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index 10e41cd..3d09c39 100644
--- a/tox.ini
+++ b/tox.ini
@@ -10,7 +10,7 @@
install_command = pip install --process-dependency-links --pre {opts} {packages}
[testenv:flake8]
-commands = flake8
+commands = flake8 {posargs}
deps = flake8
[testenv:venv]
--
To view, visit https://gerrit.wikimedia.org/r/112429
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7d75c282284cc7bba699fa01674efd328f0c0a25
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>