Skip to main content

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

idkit-1.0.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

idkit-1.0.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file idkit-1.0.2.tar.gz.

File metadata

  • Download URL: idkit-1.0.2.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

Hashes for idkit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1caf723da2c1dafa3ceb0794512d6cd8889824ee48f4c3e6ac31ed68cf037fd0
MD5 656f2a00c67da483386591dedd691eb1
BLAKE2b-256 5986b7c34c05b1e2c0f119098020ce50a644f17ee384cbf645b385adb843a8be

See more details on using hashes here.

File details

Details for the file idkit-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: idkit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for idkit-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f0debee7a1cb5dedaf8d5804a0f0ee6e435436a1fa0dea13154ed08d4f31dd87
MD5 9f6c7adaea859d06e7bd0e40acafd1b6
BLAKE2b-256 3695645642634223ea8b64f441d5cc8d69a9c95c4ad67265d70722aeefca59f0

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