Skip to main content

Mint NOIDs using a CLI or API

Project description

noid Python Package

PyPI version PyPI - Python Version example workflow codecov

Installation

Install from PyPI with

pip install noid

or from source with

pip install git+git@github.com:paulkorir/noid.git     # SSH
pip install git+https://github.com/paulkorir/noid.git # HTTPS

CLI Usage

Generating a noid

Use the noid command with no arguments:

noid

There are various options available using -h/--help:

noid -h
usage: noid [-h] [-c CONFIG_FILE] [-V | -d] [-s SCHEME] [-N NAA] [-t TEMPLATE] [-n INDEX] [-v] [noid]

generate nice and opaque identifiers

positional arguments:
  noid                  a noid

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        path to a config file with a noid section
  -V, --validate        validate the given noid [default: False]
  -d, --check-digit     compute and print the corresponding check digit for the given noid [default: False]
  -s SCHEME, --scheme SCHEME
                        the noid scheme [default: 'ark:/']
  -N NAA, --naa NAA     the name assigning authority (NAA) number [default: ]
  -t TEMPLATE, --template TEMPLATE
                        the template by which to generate noids [default: 'zeeddk']
  -n INDEX, --index INDEX
                        a number for which to generate a valid noid [default: random positive integer]
  -v, --verbose         turn on verbose text [default: False]

Validating a noid

Validate a noid using the -v/--validate flag and pass a noid.

noid -v $(noid) # self-validation

Compute the check digit for a noid

Compute the check digit using -d/--check-digit flag and pass a noid.

noid -d $(noid -t zeee -n 1234) && noid -t zeee -n 1234 && noid -t zeeek -n 1234

The example above prints out the check digit, the full noid without a check digit and the full noid with a check digit.

Options

Specify the NAA

Use the -N/--naa option.

noid --naa 1234

Specify the scheme

Use the -s/--scheme option.

noid --scheme darpa::

Specify a template

Use the -t/--template option.

noid -t zeeddeedeedk

Compute a noid for a value

Use the -n/--index option.

noid -n 42

Using a config file

A simple config file can be defined with the following structure:

# path/to/noid.cnf
[noid]
# start with 'z'; follow with as many 'e' or 'd' as needed; terminate with 'k' for a checkdigit 
template = zeededdek 
scheme = ark:/
naa = 92729
# the above configs will produce noids like so: ark:/92729/fn7Z344v

then use it as follows:

noid -c path/to/noid.cnf

API Usage

You can also use this package's API in your code.

import random

from noid import mint, validate, calculate_check_digit, generate_noid

# with default arguments
noid = mint()

# arguments: template, n, scheme, naa
noid = mint(template='zeedeeedk', n=37, scheme='https://', naa='802938')

# validating a noid
validate(noid) # True/False

# calculate the check digit
calculate_check_digit(noid)

# low-level generate a noid from a mask and number; no check digit is appended
noid = generate_noid('eeddeed', random.randint(100, 1000))

Testing

pip install -r requirements.txt
tox

Authors

See also the list of contributors who participated in this project.

Thanks

This tool was heavily influenced from noid-mint

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noid-1.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noid-1.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file noid-1.1.1.tar.gz.

File metadata

  • Download URL: noid-1.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for noid-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a565deefb4ff07c5c6707ff650496bdb8178acb41d73526a53fb655108d27a80
MD5 dbd4fbb1fdcfe6c551c09dcb80c40805
BLAKE2b-256 c9aabb762f661eee4f651bae98192739b298de7966d62821ed4345a77b0f2a62

See more details on using hashes here.

File details

Details for the file noid-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: noid-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for noid-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94c92c5a6afed78d543bea376ce99b85dc167daf11b85a7a04f114eba20b1532
MD5 3ba0de9a9ceff3fbb6cbd37237f124a9
BLAKE2b-256 00fa6aee76a94ce5565f6a74ab692cbafbe3dc8edd72a28b4a0c5a5af7524ba5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page