forked from mirrors/bookwyrm
Python formatting
This commit is contained in:
parent
66ad8c3b25
commit
bdc3f6828b
3 changed files with 7 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue