noid Python Package
Installation
Install from PyPI with
pip install noid
or from source with
pip install git+git@github.com:emdb-empiar/noid.git # SSH
pip install git+https://github.com/emdb-empiar/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
- Current implementation:
- Original source code was by:
See also the list of contributors who participated in this project.
Thanks
This tool was heavily influenced from noid-mint
References
- https://confluence.ucop.edu/display/Curation/NOID
- https://metacpan.org/dist/Noid/view/noid
- https://en.wikipedia.org/wiki/Archival_Resource_Key
- https://www.gs1.org/standards/id-keys/global-model-number-gmn
- https://www.gs1.org/sites/default/files/docs/idkeys/gs1_gmn_executive_summary.pdf
- https://www.gs1.org/services/gmn-generator
- https://en.wikipedia.org/wiki/Check_digit
Metadata
Release files for noid 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| noid-1.1.3.tar.gz | 10.6 kB | Without provenance | Details for noid-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| noid-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for noid-1.1.3-py3-none-any.whl |
Total release size: 19.3 kB
Release files / noid-1.1.3.tar.gz
| Download URL | noid-1.1.3.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed3e1f747eaf3aacbaaa73ef46c5b4b4a37a094a2fb75538f5430dfe4cb966b3
|
|
BLAKE2b-256 checksum How to use checksums |
a3a834b6ea9022f6a0ef35722969f975e71f46c53ce7f18374cb84dc15d20b98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / noid-1.1.3-py3-none-any.whl
| Download URL | noid-1.1.3-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7cbb164b7aeed2c8a681643cdb39503650bffd7052755c40a2ddeb7bbc7046e
|
|
BLAKE2b-256 checksum How to use checksums |
08e7f7a6430b61306a153a6325398515dd3773419b3520cf94b9b65bfac6e70f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for noid 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.