Fix ISBN validation and complete unittests
This commit is contained in:
parent
eb576f5fa6
commit
bed4ffff69
@ -37,7 +37,11 @@ def is_valid(isbn):
|
|||||||
>>> is_valid("123456789X")
|
>>> is_valid("123456789X")
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
return not isbnlib.notisbn(isbn)
|
return (
|
||||||
|
(not isbnlib.notisbn(isbn)) and (
|
||||||
|
isbnlib.get_canonical_isbn(isbn) == isbn or
|
||||||
|
isbnlib.mask(isbnlib.get_canonical_isbn(isbn)) == isbn)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def extract_from_text(text):
|
def extract_from_text(text):
|
||||||
|
@ -82,7 +82,8 @@ def batch(iterable, size):
|
|||||||
:params size: Size of the batches.
|
:params size: Size of the batches.
|
||||||
:returns: A new batch of the given size at each time.
|
:returns: A new batch of the given size at each time.
|
||||||
|
|
||||||
# TODO: Unittest
|
>>> [list(i) for i in batch([1, 2, 3, 4, 5], 2)]
|
||||||
|
[[1, 2], [3, 4], [5]]
|
||||||
"""
|
"""
|
||||||
it = iter(iterable)
|
it = iter(iterable)
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user