Parser for search results in connectors
This commit is contained in:
parent
c8bb717634
commit
bb01834a31
5 changed files with 18 additions and 2 deletions
|
@ -49,7 +49,7 @@ class AbstractConnector(ABC):
|
|||
data = resp.json()
|
||||
results = []
|
||||
|
||||
for doc in data['docs'][:10]:
|
||||
for doc in self.parse_search_data(data)[:10]:
|
||||
results.append(self.format_search_result(doc))
|
||||
return results
|
||||
|
||||
|
@ -82,6 +82,11 @@ class AbstractConnector(ABC):
|
|||
return book
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def parse_search_data(self, data):
|
||||
''' turn the result json from a search into a list '''
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def format_search_result(self, search_result):
|
||||
''' create a SearchResult obj from json '''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue