jenkins-bot has submitted this change and it was merged.
Change subject: Allow titletranslate.translate page to be None
......................................................................
Allow titletranslate.translate page to be None
60c01fa552 introduced a dependency in titletranslate.translate on
its page parameter, however that parameter can be None.
Fix the spec of the method to indicate it can be None, and
also rewrite the only invocation, in interwiki.py, so it is more
easily understandable.
Also deprecate unused family parameter.
Bug: T75934
Change-Id: Ifca8a1c259d34e8c43c6ab331d2dc5196f3bfb44
(cherry picked from commit 95404658bd53a9cc50d276a86a0d82d293d16ac3)
---
M pywikibot/titletranslate.py
M scripts/interwiki.py
2 files changed, 26 insertions(+), 22 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py
index 5735163..e0fe8ca 100644
--- a/pywikibot/titletranslate.py
+++ b/pywikibot/titletranslate.py
@@ -3,7 +3,7 @@
#
# (C) Rob W.W. Hooft, 2003
# (C) Yuri Astrakhan, 2005
-# (C) Pywikibot team, 2003-2014
+# (C) Pywikibot team, 2003-2015
#
# Distributed under the terms of the MIT license.
#
@@ -15,11 +15,14 @@
import pywikibot
import pywikibot.date as date
+
from pywikibot import config
+from pywikibot.tools import deprecated_args
-def translate(page, hints=None, auto=True, removebrackets=False, site=None,
- family=None):
+@deprecated_args(family=None)
+def translate(page=None, hints=None, auto=True, removebrackets=False,
+ site=None):
"""
Return a list of links to pages on other sites based on hints.
@@ -32,10 +35,12 @@
"""
result = set()
+
+ assert page or site
+
if site is None and page:
site = page.site
- if family is None and site:
- family = site.family
+
if hints:
for h in hints:
if ':' not in h:
@@ -65,13 +70,15 @@
codes = site.family.language_groups[codes]
else:
codes = codes.split(',')
+
for newcode in codes:
if newcode in site.languages():
if newcode != site.code:
+ ns = page.namespace() if page else 0
x = pywikibot.Link(newname,
site.getSite(code=newcode),
- defaultNamespace=page.namespace())
+ defaultNamespace=ns)
result.add(x)
else:
if config.verbose_output:
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index fa26860..caa6d67 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -924,24 +924,21 @@
"""Add the given translation hints to the todo
list."""
if globalvar.same and self.originPage:
if hints:
- links = titletranslate.translate(
- self.originPage,
- hints=hints + ['all:'],
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket)
+ hints += ['all:']
else:
- links = titletranslate.translate(
- self.originPage,
- hints=['all:'],
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket)
+ hints = ['all:']
+
+ site = self.originPage.site
else:
- links = titletranslate.translate(
- self.originPage,
- hints=hints,
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket,
- site=pywikibot.Site())
+ site = pywikibot.Site()
+
+ links = titletranslate.translate(
+ self.originPage,
+ hints=hints,
+ auto=globalvar.auto,
+ removebrackets=globalvar.hintnobracket,
+ site=site)
+
for link in links:
page = pywikibot.Page(link)
if globalvar.contentsondisk:
--
To view, visit
https://gerrit.wikimedia.org/r/243109
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifca8a1c259d34e8c43c6ab331d2dc5196f3bfb44
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>