code cleanup
This commit is contained in:
		| @@ -73,17 +73,18 @@ def get_book_cover_thumbnail(book, size="medium", ext="jpg"): | |||||||
| @register.filter(name="get_isni_bio") | @register.filter(name="get_isni_bio") | ||||||
| def get_isni_bio(existing, author): | def get_isni_bio(existing, author): | ||||||
|     """Returns the isni bio string if an existing author has an isni listed""" |     """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: |     if len(existing) == 0: | ||||||
|         return "" |         return "" | ||||||
|     for value in existing: |     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 value["bio"] | ||||||
|  |  | ||||||
|     return "" |     return "" | ||||||
|  |  | ||||||
|  |  | ||||||
| @register.filter(name="remove_spaces") | @register.filter(name="remove_spaces") | ||||||
| @stringfilter | @stringfilter | ||||||
| def remove_spaces(arg): | def remove_spaces(arg): | ||||||
|     """Removes spaces from argument passed in""" |     """Removes spaces from argument passed in""" | ||||||
|     return re.sub("\s","",str(arg)) |     return re.sub(r"\s", "", str(arg)) | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| """ the good stuff! the books! """ | """ the good stuff! the books! """ | ||||||
| from dateutil.parser import parse as dateparse |  | ||||||
| from re import sub | from re import sub | ||||||
|  | from dateutil.parser import parse as dateparse | ||||||
| from django.contrib.auth.decorators import login_required, permission_required | from django.contrib.auth.decorators import login_required, permission_required | ||||||
| from django.contrib.postgres.search import SearchRank, SearchVector | from django.contrib.postgres.search import SearchRank, SearchVector | ||||||
| from django.db import transaction | from django.db import transaction | ||||||
| @@ -75,7 +75,7 @@ class EditBook(View): | |||||||
|                     i |                     i | ||||||
|                     for i in isni_authors |                     for i in isni_authors | ||||||
|                     for a in author_matches |                     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 |                 # pylint: disable=cell-var-from-loop | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user