noid-wrapper is a Python library that provides a wrapper for interacting with the NOID (Nice Opaque Identifier) Perl utility.
It allows you to create NOID databases, mint and bind ARK identifiers, and perform various NOID operations.
-
Create NOID databases using templates.
-
Mint identifiers based on NOID templates.
-
Bind elements to identifiers.
-
Fetch and get details for specific identifiers.
-
Validate identifiers.
-
Bind multiple elements to an identifier in batch.
-
Process AGSL metadata files to extract and bind ARK identifiers.
- Configure re-direct functionality
- Read from/Write to files, like CSV or reports
- Better testing coverage
The project uses a YAML configuration file, config.yaml, to manage paths, templates, and logging levels. Example configuration:
NOID:
noid_path: "/usr/local/bin/noid"
db_path: "/home/srappel/noid_wrapper"
template: ["gmgs.reeeeeek", "long", "77981", "University of Wisconsin-Milwaukee Libraries", "gmgs"]
Logging:
level: "DEBUG" # Options: DEBUG, INFO, WARNING, ERROR, CRITICALThe dbcreate() method is used to create a NOID database if it does not already exist:
client = NoidClient("/path/to/config.yaml")
if not client.dbexist()[0]: # Check if the database exists
client.dbcreate()This code is in the if __name__ == "__main__" loop, so it will run if you run noid_client.py.
To mint a new identifier:
client.mint(count=1)The count defaults to 1, so you can even just run client.mint() to get a single identifier!
To bind an element to an identifier:
client.bind("identifier", "element", "value", "set")There's also a function for binding multiple elements to an identifier at the same time:
bind_params = {
"element1": "value1",
"element2": "value2",
"element3": "value3"
}
client.bind_multiple("identifier", bind_params, how="set")To fetch details for a specific identifier:
client.fetch("identifier")There's one for get as well, it works the same way.
You can recursively process metadata files in a directory and bind ARK identifiers to a NOID database:
client.bind_directory("/path/to/metadata", param_map)To run tests, use pytest
This project uses black for code formatting.
To format the code, run black . on a directory containing python files.