Skip to content

Minor ISSN and ISBN documentation fixes. #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdnum/isbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def compact(number, convert=False):

def _calc_isbn10_check_digit(number):
"""Calculate the ISBN check digit for 10-digit numbers. The number passed
should not have the check bit included."""
should not have the check digit included."""
check = sum((i + 1) * int(n)
for i, n in enumerate(number)) % 11
return 'X' if check == 10 else str(check)


def validate(number, convert=False):
"""Check if the number provided is a valid ISBN (either a legacy 10-digit
one or a 13-digit one). This checks the length and the check bit but does
one or a 13-digit one). This checks the length and the check digit but does
not check if the group and publisher are valid (use split() for that)."""
number = compact(number, convert=False)
if not isdigits(number[:-1]):
Expand Down Expand Up @@ -123,7 +123,7 @@ def isbn_type(number):

def is_valid(number):
"""Check if the number provided is a valid ISBN (either a legacy 10-digit
one or a 13-digit one). This checks the length and the check bit but does
one or a 13-digit one). This checks the length and the check digit but does
not check if the group and publisher are valid (use split() for that)."""
try:
return bool(validate(number))
Expand Down Expand Up @@ -174,7 +174,7 @@ def to_isbn10(number):

def split(number, convert=False):
"""Split the specified ISBN into an EAN.UCC prefix, a group prefix, a
registrant, an item number and a check-digit. If the number is in ISBN-10
registrant, an item number and a check digit. If the number is in ISBN-10
format the returned EAN.UCC prefix is '978'. If the convert parameter is
True the number is converted to ISBN-13 format first."""
# clean up number
Expand All @@ -198,7 +198,7 @@ def split(number, convert=False):
def format(number, separator='-', convert=False):
"""Reformat the number to the standard presentation format with the
EAN.UCC prefix (if any), the group prefix, the registrant, the item
number and the check-digit separated (if possible) by the specified
number and the check digit separated (if possible) by the specified
separator. Passing an empty separator should equal compact() though this
is less efficient. If the convert parameter is True the number is
converted to ISBN-13 format first."""
Expand Down
4 changes: 2 additions & 2 deletions stdnum/issn.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def compact(number):


def calc_check_digit(number):
"""Calculate the ISSN check digit for 10-digit numbers. The number passed
should not have the check bit included."""
"""Calculate the ISSN check digit for 8-digit numbers. The number passed
should not have the check digit included."""
check = (11 - sum((8 - i) * int(n)
for i, n in enumerate(number))) % 11
return 'X' if check == 10 else str(check)
Expand Down