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
|
def normalize_row(self, entry, mappings): # pylint: disable=no-self-use
|
||||||
"""use the dataclass to create the formatted row of data"""
|
"""use the dataclass to create the formatted row of data"""
|
||||||
remove_brackets = lambda v: re.sub(r"\[|\]", "", v) if v else None
|
remove_brackets = lambda v: re.sub(r"\[|\]", "", v) if v else None
|
||||||
normalized = {
|
normalized = {k: remove_brackets(entry.get(v)) for k, v in mappings.items()}
|
||||||
k: remove_brackets(entry.get(v)) for k, v in mappings.items()
|
isbn_13 = normalized["isbn_13"].split(", ")
|
||||||
}
|
|
||||||
isbn_13 = normalized["isbn_13"].split(', ')
|
|
||||||
normalized["isbn_13"] = isbn_13[1] if len(isbn_13) > 0 else None
|
normalized["isbn_13"] = isbn_13[1] if len(isbn_13) > 0 else None
|
||||||
return normalized
|
return normalized
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,9 @@ class ImportItem(models.Model):
|
||||||
@property
|
@property
|
||||||
def isbn(self):
|
def isbn(self):
|
||||||
"""pulls out the isbn13 field from the csv line data"""
|
"""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
|
@property
|
||||||
def shelf(self):
|
def shelf(self):
|
||||||
|
|
|
@ -52,9 +52,7 @@ class GoodreadsImport(TestCase):
|
||||||
self.assertEqual(len(import_items), 3)
|
self.assertEqual(len(import_items), 3)
|
||||||
self.assertEqual(import_items[0].index, 0)
|
self.assertEqual(import_items[0].index, 0)
|
||||||
self.assertEqual(import_items[0].data["Book Id"], "42036538")
|
self.assertEqual(import_items[0].data["Book Id"], "42036538")
|
||||||
self.assertEqual(
|
self.assertEqual(import_items[0].normalized_data["isbn_13"], '="9781250313195"')
|
||||||
import_items[0].normalized_data["isbn_13"], '="9781250313195"'
|
|
||||||
)
|
|
||||||
self.assertEqual(import_items[0].normalized_data["isbn_10"], '="1250313198"')
|
self.assertEqual(import_items[0].normalized_data["isbn_10"], '="1250313198"')
|
||||||
|
|
||||||
self.assertEqual(import_items[1].index, 1)
|
self.assertEqual(import_items[1].index, 1)
|
||||||
|
|
Loading…
Reference in a new issue