A library of common functions used when creating and managing open-xpd-uuid, a common, globally-unique name space (uuid) for Product Declarations, including HPDs and EPDs, to help users find all environmental and health information related to a single product.
Project description
open-xpd-uuid-lib
A library of common functions used when creating and managing open-xpd-uuid, a common, globally-unique name space (uuid) for Product Declarations, including HPDs and EPDs, to help users find all environmental and health information related to a single product.
Open xPD UUID (short readable GUIDs)
open-xpd-uuid
is a string that consists of 8 or 10 (8+2) alpha-numeric characters and any number of dashes.
For example: 123ABCED
, 123ABCEDAR
, ASB21M01
, avbDK93S
, -AB-11-cc-Ll---
.
GUIDs that consists of the following characters 1234567890ABCDEFGHJKMNPRQRSTUVWXYZ
(L
and O
are not mentioned)
are called "canonical". For example: 12345678
, ABCDEFG1
, 123ABCEDAR
.
GUIDs that consists of 10 characters represent 8-character guid with appended 2-character checksum.
Checksum allows to detect 1-character entry errors and character swaps, and most other errors.
Character treatment
-
or dash - is ignoredL
orl
orI
ori
- is treated as1
O
oro
- is treated as0
(zero)
Install
pip install open-xpd-uuid-lib
Supported versions
The library supports python 3.6
and higher.
Usage
Generate short readable GUID
>>> from cqd import open_xpd_uuid
>>> open_xpd_uuid.generate()
'JKGEE5PN'
Generate short readable GUID starting with specific characters set (prefix)
>>> from cqd import open_xpd_uuid
>>> open_xpd_uuid.generate('CQD')
'CQD55PG0'
Sanitize short readable GUIDs
Use sanitize
to replace ambiguous chars(0,o,O,1,L,l,I,i) with correct ones and remove dashes(-).
This function is useful to turn guid received from a user into a canonical one.
For example: as-b2-lm-oL
-> ASB21M01
>>> from cqd import open_xpd_uuid
>>> open_xpd_uuid.sanitize('as-b2-lm-oL')
'ASB21M01'
Validate short readable GUID
Use validate
to validate short readable GUID and get error description if the GUID is not valid.
validate
accepts only "canonical" GUIDs: use sanitize
function to make them "canonical".
>>> from cqd import open_xpd_uuid
>>> sanitized_guid = open_xpd_uuid.sanitize('as-b2-lm-oL')
>>> sanitized_guid
'ASB21M01'
>>> open_xpd_uuid.validate(sanitized_guid)
# no exception - the `sanitized_guid` is valid
>>> try:
... open_xpd_uuid.validate('as-b2-lm-oL')
... except open_xpd_uuid.GuidValidationError as e:
... print(e)
...
`guid` length must be 8 characters long
Generate and use checksum
>>> from cqd import open_xpd_uuid
>>> guid = open_xpd_uuid.generate()
'JKGEE5PN'
>>> checksum = open_xpd_uuid.checksum(guid)
'ME'
>>> guid_with_checksum = guid + checksum
'JKGEE5PNME'
>>> short_link = 'cqd.io/e/' + guid_with_checksum
'cqd.io/e/JKGEE5PNME'
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
Built Distribution
File details
Details for the file open-xpd-uuid-0.2.1.tar.gz
.
File metadata
- Download URL: open-xpd-uuid-0.2.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de20d38ae8d7119fecae7ae2f24efadfd0db25b99a4bc46fb4229e9317f0a05e |
|
MD5 | d583be3843ff2fc22056560e88111146 |
|
BLAKE2b-256 | 13b8b593721245ce62c2422ee0078bfc760b290637d2a8358089d7c362e2ae62 |
File details
Details for the file open_xpd_uuid-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: open_xpd_uuid-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f23fb71cc93633f564a1d2ff3ead13c0691b8b48242ef195a8e72105b7c7ecf |
|
MD5 | 8cdaed5139387e6350d0c4a553bf8ecc |
|
BLAKE2b-256 | 337c8328e3e99de5b70fe288c9e477544ae35a2d0c4611babba8051089c419e0 |