Small code cleanup

This commit is contained in:
Mouse Reeve 2020-05-10 11:29:10 -07:00
parent 470c5d4acb
commit 72b4e7da76
3 changed files with 16 additions and 13 deletions

View file

@ -17,16 +17,19 @@ class AbstractConnector(ABC):
self.book_mappings = {}
self.base_url = info.base_url
self.books_url = info.books_url
self.covers_url = info.covers_url
self.search_url = info.search_url
self.key_name = info.key_name
self.max_query_count = info.max_query_count
self.name = info.name
self.local = info.local
self.id = info.id
self.identifier = info.identifier
fields = [
'base_url',
'books_url',
'covers_url',
'search_url',
'key_name',
'max_query_count',
'name',
'identifier',
'local'
]
for field in fields:
setattr(self, field, getattr(info, field))
def is_available(self):
@ -235,7 +238,7 @@ def get_data(url):
return data
class SearchResult:
class SearchResult(object):
''' standardized search result object '''
def __init__(self, title, key, author, year):
self.title = title

View file

@ -131,7 +131,7 @@ class Connector(AbstractConnector):
def get_cover(cover_url):
''' ask openlibrary for the cover '''
''' download the cover '''
image_name = cover_url.split('/')[-1]
response = requests.get(cover_url)
if not response.ok:

View file

@ -310,7 +310,7 @@ def handle_boost(activity):
@app.task
def handle_tag(activity):
''' someone is tagging or shelving a book '''
''' someone is tagging a book '''
user = get_or_create_remote_user(activity['actor'])
if not user.local:
book = activity['target']['id']