Topic on Manual talk:Pywikibot

unable to work on items with pywikibot

5
Keystester (talkcontribs)

I have my family file, user-config.py and user-password.py in the directory that i am running the following script from

```

import os, sys

import pywikibot as pwb

pwb.config.register_families_folder(os.getcwd())

pwb.login.ClientLoginManager().login()

os.environ['PYWIKIBOT_DIR'] = os.getcwd()

site = pwb.Site()

repo = site.data_repository()

pg = pwb.ItemPage(repo, 'Q10')

pg.get()

```

i get the following error `AttributeError: DataSite instance has no attribute 'entity_sources' `.


But when i use `pg=pwb.Page(repo, 'Main Page'); print(pg.text) `, i get an output.


How do i get pywikibot to work with items on my wikidata instance ?

Xqt (talkcontribs)

Seems your wikibase family file does not define the entity_sources method. Refer wikidata_family.py or commons_family.py as a sample. Maybe we should add a abstract base class for repository families to give a better message.

Keystester (talkcontribs)

They don't have an entity_sources method either.


Edit: commons_family.py has it but wikidata_family.py's method only has a 'return {}'. I will try modifying my family file

Keystester (talkcontribs)

adding the following to my family file got it working.

```

def entity_sources(self, code):

return {}

```

Would have been nice if the documentation for third party wiki's had this mentioned

Xqt (talkcontribs)
Reply to "unable to work on items with pywikibot"