def type_and_identifier_for_urn(cls, identifier_string): if not identifier_string: return None, None m = cls.GUTENBERG_URN_SCHEME_RE.match(identifier_string) if m: type = Identifier.GUTENBERG_ID identifier_string = m.groups()[0] elif identifier_string.startswith( "http:") or identifier_string.startswith("https:"): type = Identifier.URI elif identifier_string.startswith(Identifier.URN_SCHEME_PREFIX): identifier_string = identifier_string[len(Identifier. URN_SCHEME_PREFIX):] type, identifier_string = map(urllib.unquote, identifier_string.split("/", 1)) elif identifier_string.startswith(Identifier.ISBN_URN_SCHEME_PREFIX): type = Identifier.ISBN identifier_string = identifier_string[len(Identifier. ISBN_URN_SCHEME_PREFIX):] identifier_string = urllib.unquote(identifier_string) # Make sure this is a valid ISBN, and convert it to an ISBN-13. if not (isbnlib.is_isbn10(identifier_string) or isbnlib.is_isbn13(identifier_string)): raise ValueError("%s is not a valid ISBN." % identifier_string) if isbnlib.is_isbn10(identifier_string): identifier_string = isbnlib.to_isbn13(identifier_string) elif identifier_string.startswith(Identifier.OTHER_URN_SCHEME_PREFIX): type = Identifier.URI else: raise ValueError( "Could not turn %s into a recognized identifier." % identifier_string) return (type, identifier_string)
def type_and_identifier_for_urn(cls, identifier_string): if not identifier_string: return None, None m = cls.GUTENBERG_URN_SCHEME_RE.match(identifier_string) if m: type = Identifier.GUTENBERG_ID identifier_string = m.groups()[0] elif identifier_string.startswith("http:") or identifier_string.startswith("https:"): type = Identifier.URI elif identifier_string.startswith(Identifier.URN_SCHEME_PREFIX): identifier_string = identifier_string[len(Identifier.URN_SCHEME_PREFIX):] type, identifier_string = map( urllib.unquote, identifier_string.split("/", 1)) elif identifier_string.startswith(Identifier.ISBN_URN_SCHEME_PREFIX): type = Identifier.ISBN identifier_string = identifier_string[len(Identifier.ISBN_URN_SCHEME_PREFIX):] identifier_string = urllib.unquote(identifier_string) # Make sure this is a valid ISBN, and convert it to an ISBN-13. if not (isbnlib.is_isbn10(identifier_string) or isbnlib.is_isbn13(identifier_string)): raise ValueError("%s is not a valid ISBN." % identifier_string) if isbnlib.is_isbn10(identifier_string): identifier_string = isbnlib.to_isbn13(identifier_string) elif identifier_string.startswith(Identifier.OTHER_URN_SCHEME_PREFIX): type = Identifier.URI else: raise ValueError( "Could not turn %s into a recognized identifier." % identifier_string) return (type, identifier_string)
def getISBN(zibianma): isbntry = zibianma[:-4] if len(isbntry) == 10 and isbnlib.is_isbn10(isbntry): return isbntry elif len(isbntry) == 13 and isbnlib.is_isbn13(isbntry): return isbntry elif len(isbntry) == 11 and isbnlib.is_isbn10(isbntry[:-1]): return isbntry[:-1] elif len(isbntry) == 14 and isbnlib.is_isbn13(isbntry[:-1]): return isbntry[:-1] else: return None return None
async def check(self, entry): length = self._cfg.get('isbn_length', entry, 13) if not length: return [] isbn = entry.data.get('isbn') if not isbn: return [] clean_isbn = clean(isbn) if not clean_isbn or notisbn(clean_isbn): return [] if length not in (10, 13): raise ConfigurationError( "The option 'isbn_length' must be either of 10 or 13.") if length == 10: if not is_isbn10(clean_isbn): return [(type(self).NAME, "ISBN '{}' is not of length 10.".format(isbn), "ISBN-10 would be '{}'".format(to_isbn10(clean_isbn))) ] elif length == 13: if not is_isbn13(clean_isbn): return [(type(self).NAME, "ISBN '{}' is not of length 13.".format(isbn), "ISBN-13 would be '{}'".format(to_isbn13(clean_isbn))) ] return []
def _process_isbn(isbn): # only strip quotes if wsr, reg, or consignment number, or none if re.match("^wsr|^reg|^\d{2,4}-\d{1,4}$|n/a|none", isbn, re.I): isbn = re.sub("['\"]", "", isbn) price = 0.00 # strip quotes, dashes and whitespace. convert isbn10 to isbn13. # split isbn and price if it's an extended isbn else: isbn = re.sub("[\s'\"\-]", "", isbn) price = 0.00 # note the checking for the first character of ean5 extension # if it's 5, it means price is in us dollars 0-99.99 # otherwise, we need to do price ourself. if len(isbn) == 18: if isbn[-5] == "5": price = float(isbn[-4:]) / 100 isbn = isbn[:-5] if len(isbn) == 10: if isbnlib.is_isbn10(isbn): isbn = isbnlib.to_isbn13(isbn) else: raise isbnlib.NotValidISBNError(isbn) print("isbn13_match", re.match(isbn13_regex, isbn)) if re.match(isbn13_regex, isbn): #can't use isbnlib.is_isnb13 because of internal isbns if isbnlib.check_digit13(isbn[0:12]) != isbn[12]: raise isbnlib.NotValidISBNError(isbn) else: raise isbnlib.NotValidISBNError return isbn, price
def post(self, request): env = json.loads(request.body) isbnlike = env['ISBN'] # Make sure that only isbn13 data gets in the database if is_isbn10(isbnlike): isbnlike = to_isbn13(isbnlike) # Search for a existing entry of this ISBN try: b = Book.objects.get(isbnlike=isbnlike) #isDesired=True except ObjectDoesNotExist: # if it does not exits, tries to create a new one try: b = Book(isbnlike=isbnlike) #isDesired=True b.full_clean() # Validates b.save() except ValidationError as verr: # if validation goes wrong, convert the exception message in dictionary suitable for json conversion and return this json # as a response d = dict(verr) for k in d.keys(): d[k] = d[k][0] d["messageCode"] = CREATE_BOOK_FAILED resp = JsonResponse(d) resp.status_code = 400 return resp # Add the book to the list of the current logged user. request.user.desiredBooks.add(b) return JsonResponse({ "message": "Book successfully added", "messageCode": CREATE_BOOK_SUCESS })
def isbn_lookup(isbnlike, good_reads): """ Fetch in Good Reads for a given ISBN code """ book_info = {} val = [c for c in isbnlike if c.isdigit()] isbn = ''.join(val) if isbnlib.is_isbn10(val): isbn = isbnlib.to_isbn13(val) if isbnlib.is_isbn13(isbn): try: book = good_reads.book(isbn=isbn) publisher = book.publisher if book.publisher is not None else '-' pages_qty = book.num_pages if book.num_pages is not None else int( 0) book_info.update({ 'Título': book.title, 'Autor': str(book.authors[0]), 'Editora': publisher, 'ISBN-13': isbn, 'Qtd. de Páginas': pages_qty, 'Link': book.link }) except Exception as e: logger.exception('{}'.format(e), exc_info=False) finally: return book_info else: return book_info
def search_add(isbn): db = sqlite3.connect('test.db') db.row_factory = sqlite3.Row cursor = db.cursor() if isbnlib.is_isbn13(isbn): info = isbnlib.meta(isbn) au = ", ".join(info['Authors']) addBook(cursor, info['ISBN-13'], info['Title'], au, info['Year'], info['Publisher'], getCoverSmall(isbn), getCover(isbn), getDesc(isbn)) db.commit() return search_equals(cursor, 'ISBN', isbn) elif isbnlib.is_isbn10(isbn): isbn = isbnlib.to_isbn13(isbn) info = isbnlib.meta(isbn) au = ", ".join(info['Authors']) addBook(cursor, info['ISBN-13'], info['Title'], au, info['Year'], info['Publisher'], getCoverSmall(isbn), getCover(isbn), getDesc(isbn)) db.commit() return search_equals(cursor, 'ISBN', isbn) else: print("Not a valid ISBN") return None db.commit() db.close()
def extractISBN(self): isbn = None; rsrcmgr = PDFResourceManager() retstr = StringIO() device = TextConverter(rsrcmgr, retstr, codec='utf-8', laparams=LAParams()) interpreter = PDFPageInterpreter(rsrcmgr, device) for page in PDFPage.get_pages(self.pdf, set(), maxpages=0, password="",caching=True, check_extractable=True): # Get the text from the page interpreter.process_page(page) text = retstr.getvalue() retstr.truncate(0) # Extract ISBN isbn = self.searchCodeInPage(text) if isbn: break device.close() retstr.close() # Convert to ISBN 10 and 13 if isbnlib.is_isbn10(isbn): self.isbn10 = isbn self.isbn13 = isbnlib.to_isbn13(self.isbn10) elif isbnlib.is_isbn13(isbn): self.isbn13 = isbn self.isbn10 = isbnlib.to_isbn10(self.isbn13)
def post(self, request): env = json.loads(request.body) isbnlike = env['ISBN'] # Make sure that only isbn13 data gets in the database if is_isbn10(isbnlike): isbnlike = to_isbn13(isbnlike) # Search for a existing entry of this ISBN print(isbnlike) for b in Book.objects.all(): print("\t" + b.isbnlike) try: b = request.user.desiredBooks.get(isbnlike=isbnlike) request.user.desiredBooks.remove(b) return JsonResponse({ "message": "Book successfully deleted", "messageCode": CREATE_BOOK_SUCESS }) except ObjectDoesNotExist: return JsonResponse({ "message": "Book not found", "messageCode": CREATE_BOOK_FAILED })
def check_isbn(form, field): field.data = field.data.replace("-", "").replace(" ", "") if not is_isbn10(field.data) and not is_isbn13(field.data): raise ValidationError("ISBN number is incorrect!") if Book.query.filter_by(isbn=field.data).first(): raise ValidationError("This book is already in the database.")
def add_book(data): # add book to openlibrary.org # Define a Book Object authors = [ common.Author(name=author) for author in data['authors'].split(', ') ] book = common.Book( title=data['title'], authors=authors, publisher=data['publisher'], publish_date=data['year'], pages=data['pages'], ) # Add metadata like ISBN 10 and ISBN 13 isbn = data['isbn'] if is_isbn10(isbn): book.add_id('isbn_10', isbn) elif is_isbn13(isbn): book.add_id('isbn_13', isbn) # Create a new book ol = OpenLibrary() new_book = ol.create_book(book) new_book.add_bookcover(data['cover']) new_book.work.add_subject(data['categories']) new_book.save() return new_book
def search(request): page = int(request.GET.get('p', '1')) if page < 1: page = 1 query = request.POST.get('q', '') if query == '' and 'q' in request.GET: query = request.GET.get('q', '') if isbnlib.is_isbn10(query) or isbnlib.is_isbn13(query): try: book = Book.objects.filter(verified=True).get(Q(isbn10=query) | Q(isbn13=query)) if request.user.is_authenticated: user = request.user bookshelf_set = Bookshelf.objects.filter(reader__user=user).filter(book=book) book.owned = bookshelf_set.count() == 1 return render(request, 'books/detail.html', {'book': book}) except Book.DoesNotExist: pass books = [] total = 0 if query != '': query_set = Book.objects.filter( Q(title__icontains=query) | Q(subtitle__icontains=query) | Q(authors__icontains=query)).filter(verified=True).order_by('-added_date') total = query_set.count() books = query_set[(10 * (page - 1)):10 * page] return render(request, 'books/search.html', {'q': query, 'books': books, 'total': total, 'page': page})
def isISBN(input_str): ''' Checks if the given string is an ISBN number. ''' if isbnlib.is_isbn10(input_str): return True if isbnlib.is_isbn13(input_str): return True input_str_clean = isbnlib.clean(input_str) if isbnlib.is_isbn10(input_str_clean): return True if isbnlib.is_isbn13(input_str_clean): return True return False
def check_tweet(tweet, parent=False): if parent: print("In parent") print(tweet.full_text) print(tweet.in_reply_to_status_id) if tweet.in_reply_to_status_id: tweet = api.get_status(tweet.in_reply_to_status_id, tweet_mode="extended") print(tweet.full_text) else: return [] text = tweet.full_text words = text.split() isbnlike = isbnlib.get_isbnlike(text, level='normal') print(isbnlike) print(words) for word in words: if word.startswith("http") or word.startswith("https"): print(word) resp = requests.head(word) print(resp.headers["Location"]) if "amazon" in resp.headers["Location"] and "/dp/" in resp.headers["Location"]: amazon_text = isbnlib.get_isbnlike( resp.headers["Location"], level='normal') amazon_text = list(dict.fromkeys(amazon_text)) for item in amazon_text: if isbnlib.is_isbn10(item) or isbnlib.is_isbn13(item): isbnlike.append(item) print(isbnlike) return isbnlike
def post(self, request, *args, **kwargs): action = request.POST['create'] new_order = request.session['new_order'] transactions = request.session['transactions'] grand_total = request.session['grand_total'] grand_total_paid = request.session['grand_total_paid'] form_class = self.get_form_class() form = self.get_form(form_class) context = {'form': form} if action == 'Add': isbn_maybe = request.POST['ISBN'] quantity = request.POST['Quantity'] if is_isbn10(isbn_maybe) or is_isbn13(isbn_maybe): isbn_raw = canonical(isbn_maybe) books = get_tradeable_books(isbn_raw) if len(books) == 0: context['error'] = 'Do not buy' else: book = books[0].as_book() transaction = Transaction( book=book, subtotal=transaction_subtotal(new_order, books[0], quantity), subtotal_paid=transaction_subtotal_paid( new_order, books[0], quantity), quantity=quantity, notes='') transactions.append(transaction) grand_total += transaction.subtotal grand_total_paid += transaction.subtotal_paid request.session['transactions'] = transactions request.session['grand_total'] = grand_total request.session['grand_total_paid'] = grand_total_paid else: # isbn check failed context['error'] = 'Not ISBN' elif action == 'Submit': if transactions == []: context['error'] = 'You need to add at least one book.' else: return redirect('orders:confirm') elif action == 'Cancel': transactions = [] grand_total = Decimal(0).quantize(Decimal('0.01'), rounding=ROUND_DOWN) grand_total_paid = Decimal(0).quantize(Decimal('0.01'), rounding=ROUND_DOWN) request.session['transactions'] = transactions request.session['grand_total'] = grand_total request.session['grand_total_paid'] = grand_total_paid # context['error'] = 'Cancel order' context['new_order'] = request.session['new_order'] context['transactions'] = request.session['transactions'] context['grand_total'] = request.session['grand_total'] context['grand_total_paid'] = request.session['grand_total_paid'] return render(request, self.template_name, context)
def isbn_normalizer(self, isbn): isbn = isbn.replace("-","") isbn = isbn.upper() if isbnlib.is_isbn10(isbn): isbn = isbnlib.to_isbn13(isbn) isbn = isbn.replace("-","") #TODO: ハイフンは消したい return isbn
def mangle_isbn(raw): result = dict() for value in raw.strip().split(): if isbnlib.is_isbn13(value): result['isbn13'] = isbnlib.mask(value) elif isbnlib.is_isbn10(value): result['isbn10'] = isbnlib.mask(value) return result
def clean_isbn(self): cleaned_data = self.cleaned_data isbn = cleaned_data.get("isbn") if isbnlib.is_isbn10(isbn) or isbnlib.is_isbn13(isbn): return cleaned_data else: raise forms.ValidationError("This is not a valid isbn number.")
def get_title(isbn_numbers): for isbn in isbn_numbers: cleaned_isbn = isbnlib.clean(isbn) if (isbnlib.is_isbn13(cleaned_isbn) or isbnlib.is_isbn10(cleaned_isbn)): book = isbnlib.meta(cleaned_isbn) return book['Title'] break
def clean_isbn(isbn): """Convert an ISBN to the ISBN-13 format, remove extra characters""" isbn = re.sub("[^\d]*", "", isbn) if isbnlib.is_isbn10(isbn): isbn = isbnlib.to_isbn13(isbn) return isbn
def fix_isbn(entry): if 'isbn' in entry: value = entry['isbn'] if isbnlib.is_isbn10(value): value = isbnlib.to_isbn13(value) if not isbnlib.is_isbn13(value): raise Exception(f'invalid isbn in {entry["ID"]}: {entry["isbn"]}') entry['isbn'] = isbnlib.mask(value, separator='-') return entry
def check_valid_isbn(x): """Check if it is a ISBN. Returns the isbn if it is valid. None otherwise. """ for i in range(len(x)): if isbnlib.is_isbn10(x[i:i+10]): return x[i:i+10] elif isbnlib.is_isbn13(x[i:i+13]): return x[i:i+13] return None
def newbook(): if request.method == 'POST': barcode = str(request.form['barcode']) isbn = isbnlib.canonical(request.form['isbn']) # invoice = request.form['invoice'] error = None author = None lang = None publisher = None title = None publYear = None db = get_db() # Ensure barcode has not already been inserted to Database if db.execute('SELECT id FROM new_book WHERE barcode = ?', (barcode, )).fetchone() is not None: error = 'Barcode {} is already captured.'.format(barcode) # Checks correct barcode length elif int(len(barcode)) != 24: error = '{} is an incorrect length.'.format(barcode) # ISBN Validation elif isbnlib.is_isbn10(isbn) is not True: if isbnlib.is_isbn13(isbn) is not True: error = f'{isbn} is not a valid ISBN' if error is not None: flash(error) else: try: book_lib = (isbnlib.meta(isbn, service='goob', cache='default')) # Display meta data to user. flash(book_lib) # Assign meta dictionary values to variables for insertion to DB. author = str(book_lib['Authors']) lang = book_lib['Language'] publisher = book_lib['Publisher'] title = book_lib['Title'] publYear = book_lib['Year'] # Catch exception error for book that was not found on search. except NoDataForSelectorError: flash("Book recorded: Author, Title not found.") pass # execute query and insert data db.execute( 'INSERT INTO new_book (barcode, isbn, author_id, author, lang, publisher, title, publYear)' ' VALUES (?, ?, ?, ?, ?, ?, ?, ?)', (barcode, isbn, g.user['id'], author, lang, publisher, title, publYear)) db.commit() return redirect(url_for('book.newbook')) return render_template('book/newbook.html')
def classify_isbn(isbnlike): isbn = {} isbn['canon'] = ib.canonical(isbnlike) if ib.is_isbn10(isbnlike): isbn['type'] = 'isbn10' elif ib.is_isbn10('0'+isbn['canon']): isbn['canon'] = '0'+isbn['canon'] isbn['masked'] = ib.mask(isbn['canon']) isbn['type'] = 'isbn10' elif ib.is_isbn10('00'+isbn['canon']): isbn['canon'] = '00'+isbn['canon'] isbn['masked'] = ib.mask(isbn['canon']) isbn['type'] = 'isbn10' elif ib.is_isbn13(isbn['canon']): isbn['masked'] = ib.mask(isbn['canon']) isbn['type'] = 'isbn13' else: isbn['type'] = 'invalid?' return isbn
def clean(self): data = self.cleaned_data isbn = data.get('isbn') if i.get_isbnlike(isbn): if i.is_isbn10(isbn) or i.is_isbn13(isbn): return True raise ValidationError( 'ISBN does not seem to be a ISBN13 or ISBN10') raise ValidationError('ISBN does not seem valid')
def isbn(self, value): if not value: self._isbn = '' else: try: if isbnlib.is_isbn13(value): self._isbn = isbnlib.canonical(value) elif isbnlib.is_isbn10(value): self._isbn = isbnlib.to_isbn13(value) except: raise ValueError('Invalid ISBN {}'.format(value))
def clean_ISBN(self): isbn = self.cleaned_data.get("ISBN") if isbn: if is_isbn10(isbn): isbn = to_isbn13(isbn) if "-" in isbn: isbn = isbn.replace('-', '') if "." in isbn: isbn = isbn.replace('.', '') return isbn
def get_isbn_info(isbn): if isbn.lower().startswith('isbn:'): isbn = isbn[5:] is_isbn = is_isbn10(isbn) or is_isbn13(isbn) if not is_isbn: raise ValidationError(isbn='Not a valid ISBN.') match = spreads.metadata.get_isbn_metadata(isbn) if match: return jsonify(match) else: raise ValidationError(isbn='Could not find match for ISBN.')
def add_book(): form = AddBookForm() if form.validate_on_submit(): isbn = request.form['isbn'] if isbnlib.is_isbn13(isbn): isbn = isbnlib.to_isbn10(isbn) if not isbnlib.is_isbn10(isbn): flash('Enter valid ISBN', 'error') return redirect(url_for('admin_page.add_book')) book_data = isbnlib.meta(isbn) book_cover = isbnlib.cover(isbn)
def addISBNFromUser(filename): # Get input from user UserISBN = input("Please enter ISBN (including '-'): ") # Check its legit if isbnlib.is_isbn13(UserISBN) == True or isbnlib.is_isbn10( UserISBN) == True: # Add book based on ISBN print("Saving data...") addBookToISBNLibrary(filename, UserISBN) print("Done!") else: print("Invalid ISBN")
def isbn_to_asin(isbn): # returns isbn10 (asin) clean = isbnlib.canonical(isbn) if (len(isbn) == 10): if (isbnlib.is_isbn10(clean)): return clean else: return '0' elif (len(isbn) == 13): if (isbnlib.is_isbn13(clean)): return isbnlib.to_isbn10(clean) else: return '0'
def lookup_ISBN(book_isbn): if isbnlib.is_isbn13(book_isbn): trimmed_id = isbnlib.canonical(book_isbn) webbrowser.open(f"https://isbnsearch.org/isbn/{trimmed_id}") else: if isbnlib.is_isbn10(book_isbn): trimmed_id_isbn10 = isbnlib.canonical(book_isbn) webbrowser.open(f"https://isbnsearch.org/isbn/{trimmed_id_isbn10}") else: print( "Invalid input. Please check to see if it is in either ISBN13 or ISBN10." )
def extract_identifiers_from_row(row, isbn_columns): cols = [int(x) for x in isbn_columns.split(',')] isbns = set() for isbn_column in cols: raw = row[isbn_column].strip('"=') isbns.add(raw) # Transform to ISBN 10 or 13. if isbnlib.is_isbn13(raw): isbns.add(isbnlib.to_isbn10(raw)) elif isbnlib.is_isbn10(raw): isbns.add(isbnlib.to_isbn13(raw)) return isbns
def clean_isbn(isbn): """ Checks if ISBN is valid and converts it to ISBN13 format without dashes """ if isbnlib.is_isbn10(isbn): return isbnlib.to_isbn13(isbn) elif isbnlib.is_isbn13(isbn): return isbnlib.canonical(isbn) # test if wrongly prefixed isbn10 if isbn.startswith("978"): return clean_isbn(isbn[3:]) return ""
def from_asin(cls, _db, asin, autocreate=True): """Turn an ASIN-like string into an Identifier. If the string is an ISBN10 or ISBN13, the Identifier will be of type ISBN and the value will be the equivalent ISBN13. Otherwise the Identifier will be of type ASIN and the value will be the value of `asin`. """ asin = asin.strip().replace("-", "") if isbnlib.is_isbn10(asin): asin = isbnlib.to_isbn13(asin) if isbnlib.is_isbn13(asin): type = cls.ISBN else: type = cls.ASIN return cls.for_foreign_id(_db, type, asin, autocreate)
def get_isbn_info(isbn): if isbn.lower().startswith('isbn:'): isbn = isbn[5:] is_isbn = is_isbn10(isbn) or is_isbn13(isbn) if not is_isbn: errors = {'isbn': 'Not a valid ISBN.'} return make_response(json.dumps(dict(errors=errors)), 400, {'Content-Type': 'application/json'}) match = spreads.metadata.get_isbn_metadata(isbn) if match is None: return make_response( json.dumps({'errors': {'isbn': 'Could not find match for ISBN.'}}), 404, {'Content-Type': 'application/json'}) else: return jsonify(match)
def get_isbn_info(isbn): """ Get metadata for a given ISBN number. :param isbn: ISBN number to retrieve metadata for :type isbn: str/unicode with valid ISBN-10 or ISBN-13, optionally prefixed with `isbn:` :resheader Content-Type: :mimetype:`application/json` :status 200: When the ISBN was valid and a match was found. :status 400: When the ISBN was invalid or no match was found. """ if isbn.lower().startswith('isbn:'): isbn = isbn[5:] is_isbn = is_isbn10(isbn) or is_isbn13(isbn) if not is_isbn: raise ValidationError(isbn='Not a valid ISBN.') match = spreads.metadata.get_isbn_metadata(isbn) if match: return jsonify(match) else: raise ValidationError(isbn='Could not find match for ISBN.')
def com_isbn_10_check(isbn_string): return isbnlib.is_isbn10(isbn_string)
def check_isbn(self, path, el): if not isbnlib.is_isbn13(el.text) and not isbnlib.is_isbn10(el.text): msg = 'Invalid ISBN: %s' % el.text self.add_message(msg, path, el)
def validate_isbn10(value): if not isbnlib.is_isbn10(value): raise ValidationError('%s ist keine ISBN-10 Nummer' % value)
def process_identifier(self, identifier): isbn = identifier.identifier if isbn and (isbnlib.is_isbn10(isbn) or isbnlib.is_isbn13(isbn)): self.client.measure_popularity(identifier, self.client.ONE_YEAR_AGO) return True
def verify_isbn(): isbn = request.vars.isbn.strip() return isbnlib.is_isbn10(isbn) or isbnlib.is_isbn13(isbn)
def check_value(self, value): return is_isbn10(value) or is_isbn13(value)
def get_default_isbn(isbn_list): for isbn in isbn_list: if isbnlib.is_isbn13(isbn) or isbnlib.is_isbn10(isbn): return isbnlib.mask(isbn) return ""