From 8fb082e2fc49f535c7cb8cc22fefe14b08d4e9a8 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Tue, 24 Mar 2020 16:56:53 +0000 Subject: [PATCH] Add useful reprs to books & search results for debugging. --- fedireads/connectors/abstract_connector.py | 6 +++++- fedireads/models/book.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fedireads/connectors/abstract_connector.py b/fedireads/connectors/abstract_connector.py index dfb6b99de..045e655ee 100644 --- a/fedireads/connectors/abstract_connector.py +++ b/fedireads/connectors/abstract_connector.py @@ -53,8 +53,12 @@ class AbstractConnector(ABC): class SearchResult(object): ''' standardized search result object ''' - def __init__(self, title, key, author, year): + def __init__(self, title, key, author, year, raw_data): self.title = title self.key = key self.author = author self.year = year + self.raw_data = raw_data + + def __repr__(self): + return "".format(self.key, self.title, self.author) diff --git a/fedireads/models/book.py b/fedireads/models/book.py index 04451d0db..6cdedfe2e 100644 --- a/fedireads/models/book.py +++ b/fedireads/models/book.py @@ -54,6 +54,9 @@ class Book(FedireadsModel): model_name = type(self).__name__.lower() return '%s/%s/%s' % (base_path, model_name, self.openlibrary_key) + def __repr__(self): + return "<{} key={!r} title={!r} author={!r}>".format(self.__class__, self.openlibrary_key, self.title, self.author) + class Work(Book): ''' a work (an abstract concept of a book that manifests in an edition) '''