arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
484 stars 203 forks source link

python-stdnum

A Python module to parse, validate and reformat standard numbers and codes in different formats. It contains a large collection of number formats.

Basically any number or code that has some validation mechanism available or some common formatting is eligible for inclusion in this library.

https://arthurdejong.org/python-stdnum/

Available formats

Currently this package supports the following formats:

Furthermore a number of generic check digit algorithms are available:

Basically any number or code that has some validation mechanism available or some common formatting is eligible for inclusion into this library.

These modules generally do not provide background information on the meaning and use of the specified numbers, only parsing and handling functions.

Interface

All modules implement a common interface. For example for ISBN validation:

>>> from stdnum import isbn
>>> isbn.validate('978-9024538270')
'9789024538270'
>>> isbn.validate('978-9024538271')
Traceback (most recent call last):
    ...
InvalidChecksum: ...

Most of these modules implement the following functions:

Apart from the above, the module may add extra parsing, validation or conversion functions.

Requirements

The modules should not require any external Python modules and should be pure Python. The modules are developed and tested with Python 2.7 and 3.6 but may also work with older versions of Python.

Copyright

Copyright (C) 2010-2024 Arthur de Jong and others

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Feedback and bug reports

If you have any questions regarding python-stdnum, would like to report a bug or request addition of a format please send an email to python-stdnum-users@lists.arthurdejong.org Patches and code contributions are more than welcome.