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 --- M pywikibot/titletranslate.py M scripts/interwiki.py 2 files changed, 26 insertions(+), 22 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py index f7f7b55..c535815 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 33749ea..b8084d7 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -925,24 +925,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/222606 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifca8a1c259d34e8c43c6ab331d2dc5196f3bfb44 Gerrit-PatchSet: 6 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits