Fixes linter issues

This commit is contained in:
Mouse Reeve
2020-09-21 10:25:26 -07:00
parent 4d0176a6f7
commit 425da16fd6
16 changed files with 63 additions and 42 deletions

View File

@ -162,7 +162,7 @@ class AbstractConnector(ABC):
def update_book(self, book, data=None):
''' load new data '''
if not book.sync and not book.sync_cover:
return
return book
if not data:
key = getattr(book, self.key_name)
@ -286,7 +286,7 @@ def get_data(url):
return data
class SearchResult(object):
class SearchResult:
''' standardized search result object '''
def __init__(self, title, key, author, year):
self.title = title
@ -299,7 +299,7 @@ class SearchResult(object):
self.key, self.title, self.author)
class Mapping(object):
class Mapping:
''' associate a local database field with a field in an external dataset '''
def __init__(
self, local_field, remote_field=None, formatter=None, model=None):

View File

@ -123,15 +123,15 @@ class Connector(AbstractConnector):
return data.get('docs')
def format_search_result(self, doc):
def format_search_result(self, search_result):
# build the remote id from the openlibrary key
key = self.books_url + doc['key']
author = doc.get('author_name') or ['Unknown']
key = self.books_url + search_result['key']
author = search_result.get('author_name') or ['Unknown']
return SearchResult(
doc.get('title'),
search_result.get('title'),
key,
', '.join(author),
doc.get('first_publish_year'),
search_result.get('first_publish_year'),
)

View File

@ -7,10 +7,6 @@ from .abstract_connector import AbstractConnector, SearchResult
class Connector(AbstractConnector):
''' instantiate a connector '''
def __init__(self, identifier):
super().__init__(identifier)
def search(self, query):
''' right now you can't search bookwyrm sorry, but when
that gets implemented it will totally rule '''
@ -44,18 +40,18 @@ class Connector(AbstractConnector):
return search_results
def format_search_result(self, book):
def format_search_result(self, search_result):
return SearchResult(
book.title,
book.local_id,
book.author_text,
book.published_date.year if book.published_date else None,
search_result.title,
search_result.local_id,
search_result.author_text,
search_result.published_date.year if \
search_result.published_date else None,
)
def get_or_create_book(self, remote_id):
''' this COULD be semi-implemented but I think it shouldn't be used '''
pass
def is_work_data(self, data):