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:
--
To view, visit https://gerrit.wikimedia.org/r/212888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id07e2e38efe35cf4cd8676b7ef2e8a27a6dbe296
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
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: [FIX] Handle namespace in a language-agnositc way in titletranslate.py
......................................................................
[FIX] Handle namespace in a language-agnositc way in titletranslate.py
Bug: T75934
Change-Id: I642cb7602e5717492f94990a57ebde540b6ae8b5
---
M pywikibot/titletranslate.py
1 file changed, 5 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py
index 5b86032..5735163 100644
--- a/pywikibot/titletranslate.py
+++ b/pywikibot/titletranslate.py
@@ -50,13 +50,7 @@
# we're currently working on ...
if page is None:
continue
- ns = page.namespace()
- if ns:
- newname = u'%s:%s' % (site.namespace(ns),
- page.title(withNamespace=False))
- else:
- # article in the main namespace
- newname = page.title()
+ newname = page.title(withNamespace=False)
# ... unless we do want brackets
if removebrackets:
newname = re.sub(re.compile(r"\W*?\(.*?\)\W*?",
@@ -72,9 +66,12 @@
else:
codes = codes.split(',')
for newcode in codes:
+
if newcode in site.languages():
if newcode != site.code:
- x = pywikibot.Link(newname, site.getSite(code=newcode))
+ x = pywikibot.Link(newname,
+ site.getSite(code=newcode),
+ defaultNamespace=page.namespace())
result.add(x)
else:
if config.verbose_output:
--
To view, visit https://gerrit.wikimedia.org/r/212879
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I642cb7602e5717492f94990a57ebde540b6ae8b5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>