From 0b0228737822d63f1599da3238475945f1dc9d26 Mon Sep 17 00:00:00 2001 From: Willi Hohenstein Date: Sun, 13 Feb 2022 20:49:44 +0100 Subject: [PATCH] add docstring --- bookwyrm/views/search.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py index d6257cba4..10999a322 100644 --- a/bookwyrm/views/search.py +++ b/bookwyrm/views/search.py @@ -128,16 +128,21 @@ def list_search(query, viewer, *_): def isbn_check(query): + """isbn10 or isbn13 check, if so remove separators""" if query: su_num = query.replace("-", "").replace(" ", "") if len(su_num) == 13: # Multiply every other digit by 3 # Add these numbers and the other digits - product = sum(int(ch) for ch in su_num[::2]) + sum(int(ch) * 3 for ch in su_num[1::2]) + product = sum(int(ch) for ch in su_num[::2]) + sum( + int(ch) * 3 for ch in su_num[1::2] + ) if product % 10 == 0: return su_num elif len(su_num) == 10: - if su_num[0:8].isdigit() and (su_num[9].isdigit() or su_num[9].lower() == "x"): + if su_num[0:8].isdigit() and ( + su_num[9].isdigit() or su_num[9].lower() == "x" + ): product = 0 # Iterate through code_string for i in range(9):