code cleanup

This commit is contained in:
Hugh Rundle 2021-11-01 16:00:34 +11:00
parent 775470a852
commit c845b7a5d0
2 changed files with 6 additions and 5 deletions

View file

@ -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))

View file

@ -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