From c845b7a5d0750ce9bb74e366409e5cdf05d8694b Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 1 Nov 2021 16:00:34 +1100 Subject: [PATCH] code cleanup --- bookwyrm/templatetags/utilities.py | 7 ++++--- bookwyrm/views/books/edit_book.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bookwyrm/templatetags/utilities.py b/bookwyrm/templatetags/utilities.py index 229a3d0b..7e771a17 100644 --- a/bookwyrm/templatetags/utilities.py +++ b/bookwyrm/templatetags/utilities.py @@ -73,17 +73,18 @@ def get_book_cover_thumbnail(book, size="medium", ext="jpg"): @register.filter(name="get_isni_bio") def get_isni_bio(existing, author): """Returns the isni bio string if an existing author has an isni listed""" - auth_isni = re.sub("\D","",str(author.isni)) + auth_isni = re.sub(r"\D", "", str(author.isni)) if len(existing) == 0: return "" for value in existing: - if "bio" in value and auth_isni == re.sub("\D","",str(value["isni"])): + if "bio" in value and auth_isni == re.sub(r"\D", "", str(value["isni"])): return value["bio"] return "" + @register.filter(name="remove_spaces") @stringfilter def remove_spaces(arg): """Removes spaces from argument passed in""" - return re.sub("\s","",str(arg)) + return re.sub(r"\s", "", str(arg)) diff --git a/bookwyrm/views/books/edit_book.py b/bookwyrm/views/books/edit_book.py index 939d99d0..177ee708 100644 --- a/bookwyrm/views/books/edit_book.py +++ b/bookwyrm/views/books/edit_book.py @@ -1,6 +1,6 @@ """ the good stuff! the books! """ -from dateutil.parser import parse as dateparse from re import sub +from dateutil.parser import parse as dateparse from django.contrib.auth.decorators import login_required, permission_required from django.contrib.postgres.search import SearchRank, SearchVector from django.db import transaction @@ -75,7 +75,7 @@ class EditBook(View): i for i in isni_authors for a in author_matches - if sub("\D","",str(i["isni"])) == sub("\D","",str(a.isni)) + if sub(r"\D", "", str(i["isni"])) == sub(r"\D", "", str(a.isni)) ] # pylint: disable=cell-var-from-loop