Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikidata assumption leads to bad data #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions wptools/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,14 @@ def get(self, show=True, proxy=None, timeout=0):
self.flags['defer_imageinfo'] = True

self.get_wikidata(False, proxy, timeout)
self.get_query(False, proxy, timeout)
self.get_parse(False, proxy, timeout)
if self.params.get('title'):
self.get_query(False, proxy, timeout)
self.get_parse(False, proxy, timeout)

self.flags['defer_imageinfo'] = False

self.get_restbase('/page/summary/', False, proxy, timeout)
if self.params.get('title'):
self.get_restbase('/page/summary/', False, proxy, timeout)

if show and not self.flags.get('silent'):
self.show()
Expand Down
13 changes: 8 additions & 5 deletions wptools/wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,22 @@ def _set_title(self, item):
"""
title = None
lang = self.params['lang']
label = self.data['label']
# label = self.data['label']

if item.get('sitelinks'):
for link in item['sitelinks']:
if link == "%swiki" % lang:
title = item['sitelinks'][link]['title']
self.data['title'] = title.replace(' ', '_')

if not self.data.get('title') and label:
self.data['title'] = label.replace(' ', '_')
# aw - this leads to completely incorrect data because
# it assumes that everything is in en.wikipedia later
#
# if not self.data.get('title') and label:
# self.data['title'] = label.replace(' ', '_')

if self.data.get('title') and not self.params.get('title'):
self.params['title'] = self.data['title']
# if self.data.get('title') and not self.params.get('title'):
# self.params['title'] = self.data['title']

def _set_wikidata(self):
"""
Expand Down