isbn_canonicalize#
- isbn_canonicalize(value, *, hyphenate=True, strict=False)#
Converts a ISBN into a unique, uniform format.
The provided ISBN is first validated and, if necessary, converted to an ISBN-13. The individual components are separated by hyphens.
Added in version 0.3.0.
- Parameters:
- valuestr
The value to be checked.
- hyphenatebool, default=True
Whether hyphens should be used to separate the components or not.
- strictbool, default=False
If set, a
ValueErroris raised if an invalid ISBN is passed, otherwiseNoneis returned.
- Returns:
- str
The canonical form of the given ISBN.
- Raises:
- ValueError
If the given ISBN is invalid.
Examples
>>> from marc21_learn.pid import isbn_canonicalize >>> >>> isbn_canonicalize("9783100318152") '978-3-10-031815-2' >>> isbn_canonicalize("3100318153") '978-3-10-031815-2' >>> isbn_canonicalize("9783100318152", hyphenate=False) '9783100318152'