Skip to content

Commit

Permalink
Fixed it?
Browse files Browse the repository at this point in the history
  • Loading branch information
katjabercic committed Dec 1, 2023
1 parent 6582b31 commit 4c653cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 7 additions & 2 deletions web/slurper/source_wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ def get_items(self):
raw_item = BaseWdRawItem.raw_item(self.source, json_item)
yield raw_item.to_item()
if self.source != Item.Source.WIKIDATA:
raw_item.yield_switched_if_not_exists(Item.Source.WIKIDATA)
raw_item_wd = raw_item.switch_source_to(Item.Source.WIKIDATA)
if not raw_item_wd.item_exists():
yield raw_item_wd.to_item()
if raw_item.has_source(Item.Source.WIKIPEDIA_EN):
raw_item.yield_switched_if_not_exists(Item.Source.WIKIPEDIA_EN)
raw_item_wp_en = raw_item.switch_source_to(Item.Source.WIKIPEDIA_EN)
if not raw_item_wp_en.item_exists():
yield raw_item_wp_en.to_item()


def save_items(self):
for item in self.get_items():
Expand Down
5 changes: 0 additions & 5 deletions web/slurper/wd_raw_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ def item_exists(self):
def get_item(self) -> Optional[Item]:
return self._get_item_queryset().first()

def yield_switched_if_not_exists(self, source):
switched = self.switch_source_to(source)
if not switched.item_exists():
yield switched.to_item()

def save_link_to(self, source):
target = self.switch_source_to(source)
if target is not None:
Expand Down

0 comments on commit 4c653cb

Please sign in to comment.