Page MenuHomePhabricator

Site.interwiki_prefix() should not fail if the interwiki is indirect
Open, Needs TriagePublic


Steps to reproduce

After aplying patch for T188179 the methd fails in some cases, where no direct interwiki exists, like between mediawikiwiki and cs:wikisource:

$ python shell
>>> s=pywikibot.Site('mediawiki', 'mediawiki')
>>> s2=pywikibot.Site('cs', 'wikisource')
>>> s.interwiki_prefix(s2)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/pavel/pywikibot/pywikibot/", line 972, in interwiki_prefix
    u"There is no interwiki prefix to '{0}'".format(site))
KeyError: "There is no interwiki prefix to 'wikisource:cs'"

But there is interwiki prefix, just it needs to be joined from two parts: s:cs: (or cs:s:).

There are two possible solutions:

  • teach interwiki_prefix() to glue prefix if this happens
  • leave interwiki_prefix() as is for these direct general prefixes and create some other method to do the glueing