find
This commit is contained in:
parent
a9c5fb43fe
commit
e41942ea99
28 changed files with 240 additions and 84 deletions
12
oml/utils.py
12
oml/utils.py
|
|
@ -8,7 +8,7 @@ import stdnum.isbn
|
|||
|
||||
import ox
|
||||
|
||||
from meta.utils import normalize_isbn
|
||||
from meta.utils import normalize_isbn, find_isbns
|
||||
|
||||
def valid_olid(id):
|
||||
return id.startswith('OL') and id.endswith('M')
|
||||
|
|
@ -76,16 +76,6 @@ def sort_title(title):
|
|||
title = re.sub(u'[\'!¿¡,\.;\-"\:\*\[\]]', '', title)
|
||||
return title.strip()
|
||||
|
||||
def find_isbns(text):
|
||||
matches = re.compile('\d[\d\-X\ ]+').findall(text)
|
||||
matches = [normalize_isbn(value) for value in matches]
|
||||
return [isbn for isbn in matches if stdnum.isbn.is_valid(isbn)
|
||||
and len(isbn) in (10, 13)
|
||||
and isbn not in (
|
||||
'0' * 10,
|
||||
'0' * 13,
|
||||
)]
|
||||
|
||||
def get_position_by_id(list, key):
|
||||
for i in range(0, len(list)):
|
||||
if list[i]['id'] == key:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue