Send connector with search result

also fix typo in get_work_from_edition_data function
This commit is contained in:
Mouse Reeve
2020-12-27 14:27:18 -08:00
parent 9f74e95b00
commit ac261d7b1a
6 changed files with 65 additions and 12 deletions

View File

@ -168,7 +168,7 @@ class AbstractConnector(AbstractMinimalConnector):
''' every work needs at least one edition '''
@abstractmethod
def get_work_from_edition_date(self, data):
def get_work_from_edition_data(self, data):
''' every edition needs a work '''
@abstractmethod
@ -228,6 +228,7 @@ class SearchResult:
key: str
author: str
year: str
connector: object
confidence: int = 1
def __repr__(self):

View File

@ -13,4 +13,5 @@ class Connector(AbstractMinimalConnector):
return data
def format_search_result(self, search_result):
search_result['connector'] = self
return SearchResult(**search_result)

View File

@ -85,7 +85,7 @@ class Connector(AbstractConnector):
return pick_default_edition(data['entries'])
def get_work_from_edition_date(self, data):
def get_work_from_edition_data(self, data):
try:
key = data['works'][0]['key']
except (IndexError, KeyError):
@ -123,6 +123,7 @@ class Connector(AbstractConnector):
title=search_result.get('title'),
key=key,
author=', '.join(author),
connector=self,
year=search_result.get('first_publish_year'),
)

View File

@ -51,28 +51,23 @@ class Connector(AbstractConnector):
author=search_result.author_text,
year=search_result.published_date.year if \
search_result.published_date else None,
connector=self,
confidence=search_result.rank,
)
def get_remote_id_from_data(self, data):
pass
def is_work_data(self, data):
pass
def get_edition_from_work_data(self, data):
pass
def get_work_from_edition_date(self, data):
def get_work_from_edition_data(self, data):
pass
def get_authors_from_data(self, data):
return None
def get_cover_from_data(self, data):
return None
def parse_search_data(self, data):
''' it's already in the right format, don't even worry about it '''
return data