New version of black, new whitespace

This commit is contained in:
Mouse Reeve
2021-04-26 09:15:42 -07:00
parent ef83eb33b0
commit 3ade2d3bb1
152 changed files with 1289 additions and 1289 deletions

View File

@ -20,7 +20,7 @@ GOODREADS_SHELVES = {
def unquote_string(text):
""" resolve csv quote weirdness """
"""resolve csv quote weirdness"""
match = re.match(r'="([^"]*)"', text)
if match:
return match.group(1)
@ -28,7 +28,7 @@ def unquote_string(text):
def construct_search_term(title, author):
""" formulate a query for the data connector """
"""formulate a query for the data connector"""
# Strip brackets (usually series title from search term)
title = re.sub(r"\s*\([^)]*\)\s*", "", title)
# Open library doesn't like including author initials in search term.
@ -38,7 +38,7 @@ def construct_search_term(title, author):
class ImportJob(models.Model):
""" entry for a specific request for book data import """
"""entry for a specific request for book data import"""
user = models.ForeignKey(User, on_delete=models.CASCADE)
created_date = models.DateTimeField(default=timezone.now)
@ -51,7 +51,7 @@ class ImportJob(models.Model):
retry = models.BooleanField(default=False)
def save(self, *args, **kwargs):
""" save and notify """
"""save and notify"""
super().save(*args, **kwargs)
if self.complete:
notification_model = apps.get_model(
@ -65,7 +65,7 @@ class ImportJob(models.Model):
class ImportItem(models.Model):
""" a single line of a csv being imported """
"""a single line of a csv being imported"""
job = models.ForeignKey(ImportJob, on_delete=models.CASCADE, related_name="items")
index = models.IntegerField()
@ -74,11 +74,11 @@ class ImportItem(models.Model):
fail_reason = models.TextField(null=True)
def resolve(self):
""" try various ways to lookup a book """
"""try various ways to lookup a book"""
self.book = self.get_book_from_isbn() or self.get_book_from_title_author()
def get_book_from_isbn(self):
""" search by isbn """
"""search by isbn"""
search_result = connector_manager.first_search_result(
self.isbn, min_confidence=0.999
)
@ -88,7 +88,7 @@ class ImportItem(models.Model):
return None
def get_book_from_title_author(self):
""" search by title and author """
"""search by title and author"""
search_term = construct_search_term(self.title, self.author)
search_result = connector_manager.first_search_result(
search_term, min_confidence=0.999
@ -100,60 +100,60 @@ class ImportItem(models.Model):
@property
def title(self):
""" get the book title """
"""get the book title"""
return self.data["Title"]
@property
def author(self):
""" get the book title """
"""get the book title"""
return self.data["Author"]
@property
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.data["ISBN13"])
@property
def shelf(self):
""" the goodreads shelf field """
"""the goodreads shelf field"""
if self.data["Exclusive Shelf"]:
return GOODREADS_SHELVES.get(self.data["Exclusive Shelf"])
return None
@property
def review(self):
""" a user-written review, to be imported with the book data """
"""a user-written review, to be imported with the book data"""
return self.data["My Review"]
@property
def rating(self):
""" x/5 star rating for a book """
"""x/5 star rating for a book"""
return int(self.data["My Rating"])
@property
def date_added(self):
""" when the book was added to this dataset """
"""when the book was added to this dataset"""
if self.data["Date Added"]:
return timezone.make_aware(dateutil.parser.parse(self.data["Date Added"]))
return None
@property
def date_started(self):
""" when the book was started """
"""when the book was started"""
if "Date Started" in self.data and self.data["Date Started"]:
return timezone.make_aware(dateutil.parser.parse(self.data["Date Started"]))
return None
@property
def date_read(self):
""" the date a book was completed """
"""the date a book was completed"""
if self.data["Date Read"]:
return timezone.make_aware(dateutil.parser.parse(self.data["Date Read"]))
return None
@property
def reads(self):
""" formats a read through dataset for the book in this line """
"""formats a read through dataset for the book in this line"""
start_date = self.date_started
# Goodreads special case (no 'date started' field)