jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/314857 )
Change subject: [IMPR] Provide generator settings inside (user-)fixes.py
......................................................................
[IMPR] Provide generator settings inside (user-)fixes.py
- Generator has the keyword 'generator' and may be a str
or a iterable of str which enables multiple pagegenerators arguments
- The fixes generator is invoked only if no generator is given by command
line. This enables to override the default generator given by the fixes set.
Bug: T147418
Change-Id: Id099b50b766fb87678807a2a209c5bd2dd824245
---
M scripts/replace.py
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
Zoranzoki21: Looks good to me, but someone else must approve
diff --git a/scripts/replace.py b/scripts/replace.py
index 1abd206..cd39f4c 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -128,7 +128,7 @@
"""
#
# (C) Daniel Herding, 2004-2012
-# (C) Pywikibot team, 2004-2016
+# (C) Pywikibot team, 2004-2017
#
# Distributed under the terms of the MIT license.
#
@@ -1023,6 +1023,7 @@
# Perform one of the predefined actions.
missing_fixes_summaries = [] # which a fixes/replacements miss a summary
+ generators_given = bool(genFactory.gens)
for fix_name in fixes_set:
try:
fix = fixes.fixes[fix_name]
@@ -1044,6 +1045,12 @@
set_summary = i18n.translate(site, fix['msg'], fallback=True)
else:
set_summary = None
+ if not generators_given and 'generator' in fix:
+ gen_args = fix['generator']
+ if isinstance(gen_args, basestring):
+ gen_args = [gen_args]
+ for gen_arg in gen_args:
+ genFactory.handleArg(gen_arg)
replacement_set = ReplacementList(fix.get('regex'),
fix.get('exceptions'),
fix.get('nocase'),
--
To view, visit https://gerrit.wikimedia.org/r/314857
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id099b50b766fb87678807a2a209c5bd2dd824245
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <dori.gord(a)orion.rs>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367321 )
Change subject: Raise a new exception class when we get a page with namespace < 0
......................................................................
Raise a new exception class when we get a page with namespace < 0
This could be used to handle this error in scripts more properly
Bug: T169213
Change-Id: Icb312829e575fa85c0c2d477f3e7cb904dd27bfb
---
M pywikibot/__init__.py
M pywikibot/data/api.py
M pywikibot/exceptions.py
3 files changed, 19 insertions(+), 3 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index e4000cc..348b596 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -53,7 +53,7 @@
SiteDefinitionError, NoSuchSite, UnknownSite, UnknownFamily,
UnknownExtension,
NoUsername, UserBlocked,
- PageRelatedError, IsRedirectPage, IsNotRedirectPage,
+ PageRelatedError, UnsupportedPage, IsRedirectPage, IsNotRedirectPage,
PageSaveRelatedError, PageNotSaved, OtherPageSaveError,
LockedPage, CascadeLockedPage, LockedNoPage, NoCreateError,
EditConflict, PageDeletedConflict, PageCreatedConflict,
@@ -106,7 +106,8 @@
'SiteDefinitionError', 'NoSuchSite', 'UnknownSite', 'UnknownFamily',
'UnknownExtension',
'NoUsername', 'UserBlocked', 'UserActionRefuse',
- 'PageRelatedError', 'IsRedirectPage', 'IsNotRedirectPage',
+ 'PageRelatedError', 'UnsupportedPage', 'IsRedirectPage',
+ 'IsNotRedirectPage',
'PageSaveRelatedError', 'PageNotSaved', 'OtherPageSaveError',
'LockedPage', 'CascadeLockedPage', 'LockedNoPage', 'NoCreateError',
'EditConflict', 'PageDeletedConflict', 'PageCreatedConflict',
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 6dc86d6..a84db31 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -35,7 +35,7 @@
from pywikibot.comms import http
from pywikibot.exceptions import (
Server504Error, Server414Error, FatalServerError, NoUsername,
- Error, TimeoutError, InvalidTitle
+ Error, TimeoutError, InvalidTitle, UnsupportedPage
)
from pywikibot.tools import (
MediaWikiVersion, deprecated, itergroup, ip, PY2, getargspec,
@@ -3144,6 +3144,8 @@
property which would make the value present must be in the props
parameter.
@type props: iterable of string
+ @raises InvalidTitle: Page title is invalid
+ @raises UnsupportedPage: Page with namespace < 0 is not supported yet
"""
if "pageid" in pagedict:
page._pageid = int(pagedict['pageid'])
@@ -3154,6 +3156,8 @@
if page.site.sametitle(page.title(), pagedict['title']):
if 'invalid' in pagedict:
raise InvalidTitle('%s: %s' % (page, pagedict['invalidreason']))
+ if int(pagedict['ns']) < 0:
+ raise UnsupportedPage(page)
raise AssertionError(
"Page %s has neither 'pageid' nor 'missing' attribute" % pagedict['title'])
page._contentmodel = pagedict.get('contentmodel') # can be None
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index d9dff19..52018df 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -24,6 +24,7 @@
PageRelatedError: any exception which is caused by an operation on a Page.
- NoPage: Page does not exist
+ - UnsupportedPage: Page is not supported due to a namespace restriction
- IsRedirectPage: Page is a redirect page
- IsNotRedirectPage: Page is not a redirect page
- CircularRedirect: Page is a circular redirect
@@ -227,6 +228,16 @@
pass
+class UnsupportedPage(PageRelatedError):
+
+ """Unsupported page due to namespace restriction."""
+
+ # namespaces < 0 aren't supported (T169213)
+ message = 'Page %s is not supported due to namespace restriction.'
+
+ pass
+
+
class NoMoveTarget(PageRelatedError):
"""Expected move target page not found."""
--
To view, visit https://gerrit.wikimedia.org/r/367321
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icb312829e575fa85c0c2d477f3e7cb904dd27bfb
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dereckson <dereckson(a)espace-win.org>
Gerrit-Reviewer: Huji <huji.huji(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: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #4327
Status: Broken
Duration: 2 hours, 3 minutes, and 54 seconds
Commit: 681bf23 (master)
Author: dalba
Message: family.py: Simplify category_redirects method
_get_cr_templates always sets a value for _catredirtemplates[code], therefore
checking for `if code in self._catredirtemplates` is not necessary and the
KeyError will never be raised.
Change-Id: Id94bf466063a58bf6311e6a84128f854d09c19d1
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/0309a77e1939...681bf239…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/276726355?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/378654 )
Change subject: family.py: Simplify category_redirects method
......................................................................
family.py: Simplify category_redirects method
_get_cr_templates always sets a value for _catredirtemplates[code], therefore
checking for `if code in self._catredirtemplates` is not necessary and the
KeyError will never be raised.
Change-Id: Id94bf466063a58bf6311e6a84128f854d09c19d1
---
M pywikibot/family.py
1 file changed, 1 insertion(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 4f3bd43..b708069 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1005,11 +1005,7 @@
if not hasattr(self, "_catredirtemplates") or \
code not in self._catredirtemplates:
self._get_cr_templates(code, fallback)
- if code in self._catredirtemplates:
- return self._catredirtemplates[code]
- else:
- raise KeyError("ERROR: title for category redirect template in "
- "language '%s' unknown" % code)
+ return self._catredirtemplates[code]
def _get_cr_templates(self, code, fallback):
"""Build list of category redirect templates."""
--
To view, visit https://gerrit.wikimedia.org/r/378654
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id94bf466063a58bf6311e6a84128f854d09c19d1
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/373849 )
Change subject: [bugfix] rewrite family._get_cr_templates()
......................................................................
[bugfix] rewrite family._get_cr_templates()
- category_redirect_templates is a tuple, not a list
- retrieve backlinks of all category redirect templates not for the first
item only
- use fallback if fallback is given and key found in template tuple
- keep list order for the given tuple and append the backlinks
Bug: T174041
Change-Id: I596aee7b8934c8aa022cca56679c336c098f5b5b
---
M pywikibot/family.py
1 file changed, 15 insertions(+), 13 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 9c94c1b..4f3bd43 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1016,23 +1016,25 @@
if not hasattr(self, "_catredirtemplates"):
self._catredirtemplates = {}
if code in self.category_redirect_templates:
- cr_template_list = self.category_redirect_templates[code]
- cr_list = list(self.category_redirect_templates[code])
+ cr_template_tuple = self.category_redirect_templates[code]
+ elif fallback and fallback in self.category_redirect_templates:
+ cr_template_tuple = self.category_redirect_templates[fallback]
else:
- cr_template_list = self.category_redirect_templates[fallback]
- cr_list = []
- if cr_template_list:
- cr_template = cr_template_list[0]
- # start with list of category redirect templates from family file
- cr_page = pywikibot.Page(pywikibot.Site(code, self),
- "Template:" + cr_template)
+ self._catredirtemplates[code] = []
+ return
+ cr_set = set()
+ site = pywikibot.Site(code, self)
+ tpl_ns = site.namespaces.TEMPLATE
+ for cr_template in cr_template_tuple:
+ cr_page = pywikibot.Page(site, cr_template, ns=tpl_ns)
# retrieve all redirects to primary template from API,
# add any that are not already on the list
- for t in cr_page.backlinks(filterRedirects=True, namespaces=10):
+ for t in cr_page.backlinks(filterRedirects=True,
+ namespaces=tpl_ns):
newtitle = t.title(withNamespace=False)
- if newtitle not in cr_list:
- cr_list.append(newtitle)
- self._catredirtemplates[code] = cr_list
+ if newtitle not in cr_template_tuple:
+ cr_set.add(newtitle)
+ self._catredirtemplates[code] = list(cr_template_tuple) + list(cr_set)
@deprecated('site.category_redirects()')
def get_cr_templates(self, code, fallback):
--
To view, visit https://gerrit.wikimedia.org/r/373849
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I596aee7b8934c8aa022cca56679c336c098f5b5b
Gerrit-PatchSet: 5
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: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Strainu <wiki(a)strainu.ro>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>