A typed, dot-notation identifier system for Python 3.12+.
Project description
IDKit
A small typed identifier system for Python 3.12+.
It lets you build structured identifiers using dot notation:
from idkit import ID
identifier = ID.system.runtime.agent.analyzer
print(identifier)
# system::runtime:agent-analyzer
print(identifier.namespace)
# system::runtime:agent
print(identifier.segment)
# analyzer
print(identifier.path)
# system/runtime/agent/analyzer
print(identifier.slug)
# system-runtime-agent-analyzer
print(identifier.unique("worker-1"))
# system::runtime:agent-analyzer<worker-1>
Format
Group::Source[:Component][-Role][<Unique>]
Examples:
system::runtime
system::runtime
system::runtime:agent
system::runtime:agent-analyzer
system::runtime:agent-analyzer<worker-1>
service::data:resource-ingester
manage::workflow:pipeline-runner
Type aliases
from idkit import Identifier, IDLike, IDable
Use Identifier when you want the concrete identity type.
Use IDLike when your function only needs the public identity interface.
Use IDable when your object exposes an .identifier property.
The root package also exports the generic building blocks:
from idkit import Identity, IdentityLike, Identifiable, IdentityNamespace
from idkit import IDLike
def register(identifier: IDLike) -> None:
identifier.require_complete()
print(identifier.value)
Installation
pip install idkit
Parsing
parsed = ID.parse("system::runtime:agent-analyzer")
assert parsed == ID.system.runtime.agent.analyzer
unique = ID.parse("system::runtime:agent-analyzer<worker-1>")
assert unique == ID.system.runtime.agent.analyzer.unique("worker-1")
Matching
identifier = ID.system.runtime.agent.analyzer
identifier.matches(ID.system)
# True
identifier.matches(ID.system.runtime)
# True
identifier.matches(ID.system.runtime.agent)
# True
identifier.matches(ID.service)
# False
Parent traversal
identifier = ID.system.runtime.agent.analyzer
identifier.parent
# Identifier('system::runtime:agent')
identifier.parent.parent
# Identifier('system::runtime')
identifier.parent.parent.parent
# Identifier('system')
Development
Run tests:
python3 -m pytest
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idkit-1.0.3.tar.gz.
File metadata
- Download URL: idkit-1.0.3.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b76de1be9c4cf23057e15d890db35dd5913e36d89cd6fd390a7a779824895d64
|
|
| MD5 |
40f51cfa55b7da116f6d2367ee1ddb12
|
|
| BLAKE2b-256 |
7cc20ef6a8ee434d17a3b9edfb87ce47d52623fff40fa8c4fb1df9c857c7aa0a
|
File details
Details for the file idkit-1.0.3-py3-none-any.whl.
File metadata
- Download URL: idkit-1.0.3-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
879f21b6a364d2a02cf5028b03d3aee9ceb4181fc6a569505f51f437147c77ba
|
|
| MD5 |
76ea1722b54495bc4f8971d84aa70b90
|
|
| BLAKE2b-256 |
dc6cb96f3b24fcd8078e6f621598a476bd0926ca4c5c488a3d4b7ba02d6b9486
|