Giter Site home page Giter Site logo

harens / checkdigit Goto Github PK

View Code? Open in Web Editor NEW
29.0 4.0 8.0 15.63 MB

๐Ÿ”’ An easy-to-use check digit library for data validation

Home Page: https://checkdigit.rtfd.io

License: GNU General Public License v3.0

Python 97.85% Makefile 2.15%
isbn credit-card upc luhn-algorithm luhn gtin gs1 ean verhoeff check-digit

checkdigit's Introduction

checkdigit logo

GitHub Workflow Status Codecov PyPI - Downloads CodeFactor Grade

checkdigit example


Packaging status

checkdigit is a pure Python library built for identification numbers. You want to validate a credit card number, or maybe even calculate a missing digit on an ISBN code? We've got you covered ๐Ÿ˜Ž.

Want to know more? Check out the API Reference and documentation!

Installation

MacPorts ๐ŸŽ

sudo port install py-checkdigit

PyPi ๐Ÿ

pip install checkdigit

โœจ Features

  • ๐Ÿ“ฆ Works out of the box with all supported Python versions (3.7-3.11).
  • โŒจ๏ธ PEP 561 compatible, with built in support for type checking.
  • ๐Ÿƒ Zero runtime dependencies. What you see is what you get.
  • ๐Ÿงฎ Capable of calculating missing digits or validating a block of data.
  • ๐Ÿ“ Extensive in-code comments and docstrings to explain how it works behind the scenes.

โœ… Supported Formats

For each of these formats, we provide functions to validate them and calculate missing digits.

Do you have any formats that you'd like to see supported? ๐Ÿค” Feel free to raise an issue, or even to send a pull request!

โœจ Contributors

This project follows the all-contributors specification. Contributions of any kind are welcome!

Want to help out? Check out the contributing page.

Thanks goes to these wonderful people (emoji key):


Timothy Langer

โš ๏ธ ๐Ÿ“–

Charlie Wilson

๐Ÿ’ป โš ๏ธ

Max Bowman

๐Ÿ’ป โš ๏ธ

Mohsen BANAN

๐Ÿ›

๐Ÿ“™ License

This project is licensed under GPL-3.0-or-later.

checkdigit's People

Contributors

allcontributors[bot] avatar deepsourcebot avatar dependabot-preview[bot] avatar dependabot[bot] avatar harens avatar imgbotapp avatar mend-bolt-for-github[bot] avatar otherbarry avatar sapieninja avatar zeevox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

checkdigit's Issues

CLI Tool

There are many examples of python libraries that also feature CLI Tools (such as uvicorn)

There are various tools to accomplish this. However, the flags will have to be considered since there are lots of functions (validate10, missing, etc.)

Fix Travis Deployment

Travis Deployment is currently failing due to HTTPError: 403 Client Error: Invalid or non-existent authentication information

An example of this is Build #16

It is hoped that bdcb7dd will fix this

Additional Tests

Having more tests can never be a bad thing!

Tests can be found in the tests.py file. An example would be the following:

test(isbn.missing("?131103628"), "0")

The first parameter of test is the function to be tested, and the second is the expected value.

EDIT: This issue will be an ongoing issue, since when new features are added, more tests will be required.

Document Makefile methods

Following from c6f2e58, the shell scripts were replaced with a Makefile.

It might be useful to somehow document the various attributes that it provides.

Add mypy + pylint to tests

The code is currently fully type-checked, so it shouldn't be that hard to get mypy tests passing. Some of the code might need to be reformatted for pylint to work properly.

Fix PyPi Formatting

See here.

Currently, a separate README has to be used, since PyPi understandably doesn't like HTML in the rst file.

This means that the gif is currently broken, and a different file to the main README has to be maintained

Refactor ISBN Functions

The ISBN Functions can also be used for various other codes, including Bookland, EAN-13 and EAN-8.

It might be useful to refactor it such that there aren't different functions for different lengths (i.e. only one validation functions).

Also, find a generic name for these types of codes, and collect it all under one heading.

Show Example Code

Showing example code in the README will help to show features

It will also help to improve understanding

For ISBN13 calculate and validate, when the checksum is 0 returned value is X instead

bookUtils.cs -i isbnCalculate13 978-1-960957-03
Returns X --- instead of 0

bookUtils.cs -i isbnValidate13 978-1-960957-03-X --- Returns True
bookUtils.cs -i isbnValidate13 978-1-960957-03-0 --- Returns False

978-1-960957-03-0 is a valid ISBN13.

Returning X instead of 0 seems to be by design, but why?

If it is not by design, then it is a bug.

P.S. bookUtils.cs is just a python command service that uses checkdigit.isbn

Support EAN-8 and UPC-E

EAN-13 and UPC-A, the two more common variants of each standard, are currently supported. It would be useful if EAN-8 and UPC-E, which are generally of a smaller size, are also supported.

See here for details about EAN/UPC barcodes.

Update API Short Descriptions

See here

Currently, the short descriptions aren't very descriptive, e.g. ISBN Validation Functions.

Maybe it can be improved by saying what it actually is, similar to the wiki first line on the code.

Script for setting up environment/linting

The commands required are currently documented in the README. It would be useful to have it all in one script to make it easier to setup.

This would also help when more commands are added in the future. It could also be this file that is run by GitHub Actions.

Move from GitHub Wiki to RTD

This was done with seaport, and so should be a similar process here.

This can allow us to automatically build the docs rather than updating it manually by hand with each new feature. This would however mean converting the markdown into rst.

Error handling

At the moment, there is very little error handling and defensive programming.

Small things such as detecting if there are invalid characters or whether the size is wrong (and then throwing an error) can help to improve the user experience.

This should be quite straight forward to do, and so this should be a good task for any new contributors!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.