jenkins-bot has submitted this change and it was merged.
Change subject: Use site.code instead of site.lang in interwiki.py ......................................................................
Use site.code instead of site.lang in interwiki.py
It can causes tons of bugs including problems in dump reading, summary i18n, user-config.py checks, etc.
One of them: Bug: T92822
Change-Id: Id07e2e38efe35cf4cd8676b7ef2e8a27a6dbe296 --- M scripts/interwiki.py 1 file changed, 15 insertions(+), 13 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 1985406..93bd89f 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -1687,7 +1687,7 @@ (not frgnSiteDone and site != lclSite and site in new): if site == lclSite: lclSiteDone = True # even if we fail the update - if site.family.name in config.usernames and site.lang in config.usernames[site.family.name]: + if site.family.name in config.usernames and site.code in config.usernames[site.family.name]: try: if self.replaceLinks(new[site], new): updatedSites.append(site) @@ -1784,7 +1784,7 @@
# if we have an account for this site if site.family.name in config.usernames and \ - site.lang in config.usernames[site.family.name] and \ + site.code in config.usernames[site.family.name] and \ smallWikiAllowed and \ not site.has_transcluded_data: # Try to do the changes @@ -1969,7 +1969,7 @@ # Allow for special case of a self-pointing interwiki link if removing and removing != [page.site]: self.problem(u'Found incorrect link to %s in %s' - % (", ".join([x.lang for x in removing]), page), + % (", ".join([x.code for x in removing]), page), createneed=False) ask = True if globalvar.force or globalvar.cleanup: @@ -2047,7 +2047,7 @@ raise GiveUpOnPage(u'User asked us to give up') else: raise LinkMustBeRemoved(u'Found incorrect link to %s in %s' - % (", ".join([x.lang for x in removing]), + % (", ".join([x.code for x in removing]), page))
def reportBacklinks(self, new, updatedSites): @@ -2149,7 +2149,7 @@ dumpfn = pywikibot.config.datafilepath( 'data', 'interwiki-dumps', - '%s-%s.pickle' % (site.family.name, site.lang) + '%s-%s.pickle' % (site.family.name, site.code) ) if append: mode = 'appended' @@ -2158,7 +2158,7 @@ titles = [s.originPage.title() for s in self.subjects] with open(dumpfn, mode[0] + 'b') as f: pickle.dump(titles, f, protocol=config.pickle_protocol) - pywikibot.output(u'Dump %s (%s) %s.' % (site.lang, site.family.name, mode)) + pywikibot.output(u'Dump %s (%s) %s.' % (site.code, site.family.name, mode)) return dumpfn
def generateMore(self, number): @@ -2204,7 +2204,7 @@ if page.namespace() == 10: loc = None try: - tmpl, loc = moved_links[page.site.lang] + tmpl, loc = moved_links[page.site.code] del tmpl except KeyError: pass @@ -2215,7 +2215,9 @@
if self.generateUntil: until = self.generateUntil - if page.site.lang not in page.site.family.nocapitalize: + page_namespace = ( + page.site.namespaces[int(page.namespace())]) + if page_namespace.case == 'first-letter': until = first_upper(until) if page.title(withNamespace=False) > until: raise StopIteration @@ -2382,7 +2384,7 @@ fmt = lambda d, site: unicode(d[site]) else: # Use short format, just the language code - fmt = lambda d, site: site.lang + fmt = lambda d, site: site.code
mods = mcomment = u''
@@ -2412,7 +2414,7 @@ 'modifying': ', '.join(fmt(new, x) for x in modifying), 'from': u'' if not useFrom else old[modifying[0]]}
- mcomment += i18n.twtranslate(insite.lang, commentname, changes) + mcomment += i18n.twtranslate(insite, commentname, changes) mods = i18n.twtranslate('en', commentname, en_changes)
return mods, mcomment, adding, removing, modifying @@ -2421,13 +2423,13 @@ def botMayEdit(page): tmpl = [] try: - tmpl, loc = moved_links[page.site.lang] + tmpl, loc = moved_links[page.site.code] except KeyError: pass if not isinstance(tmpl, list): tmpl = [tmpl] try: - tmpl += ignoreTemplates[page.site.lang] + tmpl += ignoreTemplates[page.site.code] except KeyError: pass tmpl += ignoreTemplates['_default'] @@ -2570,7 +2572,7 @@ dumpFileName = pywikibot.config.datafilepath( 'data', 'interwiki-dumps', - u'%s-%s.pickle' % (site.family.name, site.lang) + u'%s-%s.pickle' % (site.family.name, site.code) ) try: with open(dumpFileName, 'rb') as f: