Last modified: 2014-10-14 12:17:33 UTC
Expected output: $ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pywikibot >>> pywikibot.Link("en:", pywikibot.Site("commons", "commons")).site Site("en", "wikipedia") >>> pywikibot.Link("wikipedia:", pywikibot.Site("commons", "commons")).site Site("en", "wikipedia") ---- In fact: $ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pywikibot >>> pywikibot.Link("en:", pywikibot.Site("commons", "commons")).site Site("commons", "commons") >>> pywikibot.Link("wikipedia:", pywikibot.Site("commons", "commons")).site Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pywikibot/page.py", line 3777, in site self.parse() File "pywikibot/page.py", line 3700, in parse newsite = pywikibot.Site(otherlang, familyName) File "pywikibot/__init__.py", line 528, in Site _sites[key] = __Site(code=code, fam=fam, user=user, sysop=sysop) File "pywikibot/site.py", line 1186, in __init__ BaseSite.__init__(self, code, fam, user, sysop) File "pywikibot/site.py", line 449, in __init__ % (self.__code, self.__family.name)) pywikibot.exceptions.NoSuchSite: Language commons does not exist in family wikipedia
This looks like a bug: >>> pywikibot.Link("en:Main Page", pywikibot.Site("commons", "commons")).site Site("commons", "commons") >>> pywikibot.Link("en:Main Page", pywikibot.Site("de", "wikipedia")).site Site("en", "wikipedia")
Definitely a valid use case which doesnt work. It is uppercasing the first letter, which means it thinks it is a page title with a namespace. >>> pywikibot.Link("en:", pywikibot.Site("commons", "commons")).title u'En:' >>> pywikibot.Link("en:Main Page", pywikibot.Site("commons", "commons")).title u'En:Main Page' While I didnt know about this bug, this changeset was started to identify the problem, so we can track fixing it. https://gerrit.wikimedia.org/r/#/c/149629/
Change 157337 had a related patch set uploaded by Zhuyifei1999: Add support for single-lang families -> multi-lang families interfamily link https://gerrit.wikimedia.org/r/157337
Change 157337 abandoned by Zhuyifei1999: Add support for single-lang families -> multi-lang families interfamily link Reason: Looks like Iec4f32fdefde15b2330dbb191fb3bbb0d04803e2 can do a better job on this. https://gerrit.wikimedia.org/r/157337
Fixed in Iec4f32fdefde15b2330dbb191fb3bbb0d04803e2