From c59c08f3047eac151ef7416d897868538ae5a1d3 Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Thu, 1 Aug 2024 23:35:02 +0800 Subject: [PATCH] Fix typos Found via `codespell -H` and `typos --hidden --format brief` --- isbnlib/_ext.py | 16 ++++++++-------- isbnlib/dev/_exceptions.py | 4 ++-- isbnlib/dev/_helpers.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/isbnlib/_ext.py b/isbnlib/_ext.py index 883bfc4..ac0a997 100644 --- a/isbnlib/_ext.py +++ b/isbnlib/_ext.py @@ -59,25 +59,25 @@ def ren(fp): if not isbn: # pragma: no cover return None data = meta(isbn) - author = data.get('Authors', 'UNKOWN') - if author != 'UNKOWN': # pragma: no cover + author = data.get('Authors', 'UNKNOWN') + if author != 'UNKNOWN': # pragma: no cover author = last_first(author[0])['last'] - year = data.get('Year', 'UNKOWN') + year = data.get('Year', 'UNKNOWN') maxlen = 98 - (20 + len(author) + len(year)) - title = data.get('Title', 'UNKOWN') - if title != 'UNKOWN': + title = data.get('Title', 'UNKNOWN') + if title != 'UNKNOWN': regex1 = re.compile(r'[.,_!?/\\]') regex2 = re.compile(r'\s\s+') title = regex1.sub(' ', title) title = regex2.sub(' ', title) title = title.strip() - if title == 'UNKOWN' or not title: # pragma: no cover + if title == 'UNKNOWN' or not title: # pragma: no cover return None if ' ' in title: # pragma: no cover tokens = title.split(' ') stitle = cutoff_tokens(tokens, maxlen) title = ' '.join(stitle) - isbn13 = data.get('ISBN-13', 'UNKOWN') + isbn13 = data.get('ISBN-13', 'UNKNOWN') new_name = f'{author}{year}_{title}_{isbn13}' return cfp.baserename(new_name + cfp.ext) @@ -89,6 +89,6 @@ def cover(isbn): def desc(isbn): - """Return a descripion of the ISBN.""" + """Return a description of the ISBN.""" isbn = EAN13(isbn) return goo_desc(isbn) if isbn else '' diff --git a/isbnlib/dev/_exceptions.py b/isbnlib/dev/_exceptions.py index 4979420..13d305e 100644 --- a/isbnlib/dev/_exceptions.py +++ b/isbnlib/dev/_exceptions.py @@ -28,13 +28,13 @@ def __str__(self): class ISBNLibHTTPError(ISBNLibDevException): """Exception raised for HTTP related errors.""" - message = 'an HTTP error has ocurred' + message = 'an HTTP error has occurred' class ISBNLibURLError(ISBNLibDevException): """Exception raised for URL related errors.""" - message = 'an URL error has ocurred' + message = 'an URL error has occurred' class DataNotFoundAtServiceError(ISBNLibDevException): diff --git a/isbnlib/dev/_helpers.py b/isbnlib/dev/_helpers.py index 01b0d68..a58e110 100644 --- a/isbnlib/dev/_helpers.py +++ b/isbnlib/dev/_helpers.py @@ -5,7 +5,7 @@ from hashlib import md5 -def fake_isbn(title, author='unkown', publisher='unkown', sid=1): +def fake_isbn(title, author='unknown', publisher='unknown', sid=1): """Produce a fake ISBN from the (title, author, publisher) of the book.""" key = f'{title} {author} {publisher}' # normalize