From bdc3f6828ba476e4855f0b7922bd599240490182 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 14 Nov 2021 07:11:48 -0800 Subject: [PATCH] Python formatting --- bookwyrm/importers/librarything_import.py | 6 ++---- bookwyrm/models/import_job.py | 6 ++++-- bookwyrm/tests/importers/test_goodreads_import.py | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bookwyrm/importers/librarything_import.py b/bookwyrm/importers/librarything_import.py index cff6ba7d..1b61a6f1 100644 --- a/bookwyrm/importers/librarything_import.py +++ b/bookwyrm/importers/librarything_import.py @@ -13,10 +13,8 @@ class LibrarythingImporter(Importer): def normalize_row(self, entry, mappings): # pylint: disable=no-self-use """use the dataclass to create the formatted row of data""" remove_brackets = lambda v: re.sub(r"\[|\]", "", v) if v else None - normalized = { - k: remove_brackets(entry.get(v)) for k, v in mappings.items() - } - isbn_13 = normalized["isbn_13"].split(', ') + normalized = {k: remove_brackets(entry.get(v)) for k, v in mappings.items()} + isbn_13 = normalized["isbn_13"].split(", ") normalized["isbn_13"] = isbn_13[1] if len(isbn_13) > 0 else None return normalized diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index b47379bb..753662d6 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -127,7 +127,9 @@ class ImportItem(models.Model): @property def isbn(self): """pulls out the isbn13 field from the csv line data""" - return unquote_string(self.normalized_data["isbn_13"]) or unquote_string(self.normalized_data["isbn_10"]) + return unquote_string(self.normalized_data["isbn_13"]) or unquote_string( + self.normalized_data["isbn_10"] + ) @property def shelf(self): @@ -200,7 +202,7 @@ class ImportItem(models.Model): def __repr__(self): # pylint: disable=consider-using-f-string - return "<{!r}Item {!r}>".format(self.index, self.normalized_data["title"]) + return "<{!r} Item {!r}>".format(self.index, self.normalized_data["title"]) def __str__(self): # pylint: disable=consider-using-f-string diff --git a/bookwyrm/tests/importers/test_goodreads_import.py b/bookwyrm/tests/importers/test_goodreads_import.py index 4a043b59..0a421df4 100644 --- a/bookwyrm/tests/importers/test_goodreads_import.py +++ b/bookwyrm/tests/importers/test_goodreads_import.py @@ -52,9 +52,7 @@ class GoodreadsImport(TestCase): self.assertEqual(len(import_items), 3) self.assertEqual(import_items[0].index, 0) self.assertEqual(import_items[0].data["Book Id"], "42036538") - self.assertEqual( - import_items[0].normalized_data["isbn_13"], '="9781250313195"' - ) + self.assertEqual(import_items[0].normalized_data["isbn_13"], '="9781250313195"') self.assertEqual(import_items[0].normalized_data["isbn_10"], '="1250313198"') self.assertEqual(import_items[1].index, 1)