Skip to content

Commit

Permalink
v0.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
harens committed Jun 21, 2021
1 parent 0c4f368 commit e8edb5e
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 338 deletions.
144 changes: 25 additions & 119 deletions PYPIREADME.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
.. image:: https://raw.githubusercontent.com/harens/checkdigit/master/art/logo.png
:alt: checkdigit logo
:target: https://github.com/harens/checkdigit
:align: center

|
.. image:: https://img.shields.io/github/workflow/status/harens/checkdigit/Tests?logo=github&style=flat-square
:alt: GitHub Tests status
:target: https://github.com/harens/checkdigit/actions

.. image:: https://img.shields.io/codecov/c/github/harens/checkdigit?logo=codecov&style=flat-square
:alt: Codecov
:target: https://app.codecov.io/gh/harens/checkdigit

.. image:: https://img.shields.io/pypi/dm/checkdigit?logo=python&logoColor=white&style=flat-square
:alt: PyPi - Downloads
:target: https://pepy.tech/project/checkdigit

.. image:: https://img.shields.io/codefactor/grade/github/harens/checkdigit?logo=codefactor&style=flat-square
:alt: CodeFactor Grade
:target: https://www.codefactor.io/repository/github/harens/checkdigit/

.. image:: https://img.shields.io/lgtm/grade/python/github/harens/checkdigit?logo=lgtm&style=flat-square
:alt: LGTM Grade
:target: https://lgtm.com/projects/g/harens/checkdigit/

|
=========

.. image:: https://raw.githubusercontent.com/harens/checkdigit/master/art/demo.gif
:alt: checkdigit example gif
:align: center
.. image:: https://repology.org/badge/vertical-allrepos/python:checkdigit.svg
:alt: checkdigit repology
:target: https://repology.org/project/python:checkdigit/versions
:align: right

**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?
Expand Down Expand Up @@ -58,15 +65,18 @@ Installation
✅ Supported Formats
---------------------

* Even and odd binary parity
* Bookland
* CRC (credit to `@sapieninja <https://github.com/sapieninja>`_)
* EAN-13
* GS1 (credit to `@OtherBarry <https://github.com/OtherBarry>`_)
* ISBN-10
* ISBN-13
* Luhn
* UPC-A
* `Even/Odd binary parity <https://checkdigit.readthedocs.io/en/latest/_autosummary/checkdigit.parity.html#module-checkdigit.parity>`_
* `CRC <https://checkdigit.readthedocs.io/en/latest/_autosummary/checkdigit.crc.html#module-checkdigit.crc>`_
(credit to `@sapieninja <https://github.com/sapieninja>`_)
* `GS1 Standards <https://checkdigit.readthedocs.io/en/latest/_autosummary/checkdigit.gs1.html#module-checkdigit.gs1>`_ (credit to `@OtherBarry <https://github.com/OtherBarry>`_)
* EAN-8/13
* GDTI
* GLN
* SSCC
* UPC-A/E
* etc. *(all fixed length numeric GS1 data structures with a check digit)*
* `ISBN-10/13 <https://checkdigit.readthedocs.io/en/latest/_autosummary/checkdigit.isbn.html#module-checkdigit.isbn>`_
* `Luhn <https://checkdigit.readthedocs.io/en/latest/_autosummary/checkdigit.luhn.html#module-checkdigit.luhn>`_

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

Expand All @@ -76,119 +86,15 @@ or even to send a pull request!
🔨 Contributing
---------------

- Contributing Page: `<https://checkdigit.rtfd.io/en/latest/contributing.html>`_
- Issue Tracker: `<https://github.com/harens/checkdigit/issues>`_
- Source Code: `<https://github.com/harens/checkdigit>`_

Any change, big or small, that you think can help improve this project is more than welcome 🎉.

As well as this, feel free to open an issue with any new suggestions or bug reports. Every contribution is appreciated.

🏗 Setup
*********

First, fork the project to your account. Then, run the following with your GitHub handle in place of
:code:`INSERT_GITHUB_NAME`:

.. code-block:: console
git clone https://github.com/INSERT_GITHUB_NAME/checkdigit
poetry install && poetry shell
pre-commit install
🏛 Project structure
********************

..
Credit for file structure: https://stackoverflow.com/a/38819161
::

checkdigit
├── scripts
│ ├── format.sh
│ └── tests.sh
├── checkdigit
│ ├── gs1.py
│ ├── isbn.py
│ ├── luhn.py
│ └── etc.
└── tests

Each new format goes into a separate file which is named accordingly. Similar formats (e.g. ISBN-10 and ISBN-13)
should go in the same file.

Before submitting any new changes, please run the :code:`format.sh` and :code:`tests.sh` scripts beforehand. Thank you :)

📚 Building the Docs
*********************

The documentation can be found in :code:`docs/source`.

We can use `sphinx-autobuild <https://github.com/executablebooks/sphinx-autobuild>`_ to continuously rebuild the docs when changes are made.

.. code-block:: console
sphinx-autobuild docs/source docs/_build/html
🎪 File structure
*****************

Each of the Python files follow the same general format:

.. code-block:: python
# License + File docstring
from checkdigit._data import cleanse, convert
def calculate(data: str) -> str:
"""Determines check digit.
Args:
data: A string of data missing a check digit
Returns:
str: The single missing check digit (not the whole block of data)
"""
# This helps to deal with user formatting inconsistencies
# e.g. spaces, hyphens, etc.
data = cleanse(data)
# Deals with 10 or 11 being the possible check digit
return convert(...)
def validate(data: str) -> bool:
"""Validates a block of data from the check digit.
Args:
data: A string representing a full block of data
Returns:
bool: A boolean representing whether the data is valid or not
"""
data = cleanse(data)
# Remove the check digit and see if it matches
return calculate(data[:-1]) == data[-1]
def missing(data: str) -> str:
"""Returns the missing digit from a block of data.
Args:
data: A string with a question mark in the place of a missing digit.
Returns:
A string representing the missing digit (not the whole block of data)
"""
data = cleanse(data)
return ...
For similar data formats, the names can be adjusted accordingly (e.g. :code:`validate10` for ISBN-10 and :code:`validate13` for ISBN-13).
To find out more, please read our `contributing page <https://checkdigit.readthedocs.io/en/latest/contributing.html>`_. Thank you!

📙 License
-----------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Changelog
**********

WIP
====
0.3.0 (2021-06-21)
===================

🔨 Compatibility Broken
-------------------------
Expand Down
Loading

0 comments on commit e8edb5e

Please sign in to comment.