lokal-profil / wikidata-stuff

Pywikibot framework for importing and sourcing statements on Wikidata
MIT License
5 stars 3 forks source link

Handle multilingual/multioptional variables #7

Open lokal-profil opened 9 years ago

lokal-profil commented 9 years ago

Currently tracked through calls to foobar()

Functions handling variables of the form {"@language": "xx", "@value": "xxx"} (with the exception of dbpedia2Wikidata) should be prepared to receive either this or a list of these and must be able to handle either.

In addition to e.g.:

if isinstance(name, dict):
    name = [name, ]
for n in name:
   ...

the functions must also be adapted since they are currently expected to either return only one hit or to perform an edit.

For the later care must be taken since the item must be reloaded for the change to be detectable. I.e. if an [sv] label is added the second [sv] suggestion would attempt to overwrite this instead of adding that as an alias.

lokal-profil commented 9 years ago

Note that simply doing item.get() or item.exists() is not enough. The item must be recreated before any subsequent update:

item = pywikibot.ItemPage(k.repo, item.title())
item.exists()
lokal-profil commented 7 years ago

This should be moved to the lokal-profil/wikidata_batches (kulturnavbot) repo then closed