Page MenuHomePhabricator

Pywikibot fails when importing entity Q1410828
Closed, InvalidPublicBUG REPORT

Description

Steps to Reproduce:

item = pywikibot.ItemPage(wikidata_repo, "Q1410828")
item.get()

Actual Results:

  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/page.py", line 4541, in get
    self.sitelinks[dbname] = self._content['sitelinks'][dbname]
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/page.py", line 6444, in __setitem__
    val = SiteLink.fromJSON(val, self.repo)
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/page.py", line 6385, in fromJSON
    sl = cls(data['title'], data['site'])
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/page.py", line 6329, in __init__
    site, namespace, title = SiteLink._parse_namespace(title, site)
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/page.py", line 6353, in _parse_namespace
    site = pywikibot.site.APISite.fromDBName(site)
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/site.py", line 1888, in fromDBName
    return cls(lang, site['code'])
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/site.py", line 1840, in __init__
    BaseSite.__init__(self, code, fam, user, sysop)
  File "/Users/Dennis/Library/Python/3.6/lib/python/site-packages/pywikibot/site.py", line 777, in __init__
    % (self.__code, self.__family.name))
pywikibot.exceptions.UnknownSite: Language 'ban' does not exist in family wikipedia
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.UnknownSite'>

Expected Results:

I expect that the entity can be imported normally.

The error message is quite clear, but for me it is not clear how to handle that case. How can I add 'ban' to the wikipedia family? Should it not be contained by default? Is there a way to synchronise the languages supported by wikidata and the one supported in the pywikibot?

Thank you
D063520

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptNov 15 2019, 11:28 AM
Mpaa added a subscriber: Mpaa.Nov 15 2019, 8:57 PM

Works for me, ban is already in wikipedia_family.py.
It is quite slow, though.

E.g., I get this sitelink:
'banwiki': pywikibot.page.SiteLink('banwiki', 'Kategori:Jerman', []),

Mhmmmm, I use this version of Pywikibot: pywikibot-3.0.dev0
could that be the problem?

Dvorapa added a subscriber: Dvorapa.EditedNov 15 2019, 10:30 PM

Mhmmmm, I use this version of Pywikibot: pywikibot-3.0.dev0
could that be the problem?

Have you installed Pywikibot using PyPI? At PyPI the last release is from July I guess.

yes, I did:

pip install pywikibot

and I checked, there the Wikipedia Family file does not contain "ban". Should I clone the repository?

Mhmmm .... on github I cannot find the "ban" language in the wikipedia_family:

https://github.com/wikimedia/pywikibot/blob/cbf194a60124fece9355517030aaa7091dcc093a/pywikibot/families/wikipedia_family.py

So would the newest version solve my problem?

Mpaa added a comment.Nov 15 2019, 11:12 PM

Mhmmm .... on github I cannot find the "ban" language in the wikipedia_family:
https://github.com/wikimedia/pywikibot/blob/cbf194a60124fece9355517030aaa7091dcc093a/pywikibot/families/wikipedia_family.py
So would the newest version solve my problem?

why are you looking at that particular commit instead of master?
If that's your latest, that you need to update.

Ahhh, my mistake, ok, fine for me. I saw that you opened this:
https://phabricator.wikimedia.org/T238405
So for me we can close this one.
Thank you very much for the help!

Mpaa closed this task as Invalid.Nov 16 2019, 9:03 AM