Skip to main content

The DazzleLib bedrock: shared Protocols, TypedDict payload schemas, and exception root for the dazzle-* library stack. Stdlib-only by charter.

Project description

dazzle-lib

The DazzleLib stack's bedrock: shared Protocols, TypedDict payload schemas, and the exception root.

PyPI Python License: MIT Platforms

Every dazzle-* library (the stack) builds on this package: it defines what stack objects can be expected to do (view themselves, serialize themselves) and what shapes cross-layer payloads have. Types only -- by charter this package contains no I/O, no path handling, no platform probing, and no behavior, forever.

pip install dazzle-lib

What's inside (all of it)

Module Contents
dazzle_lib.protocols Viewable (summary()/__str__), Serializable (to_dict/from_dict/to_json, SCHEMA_VERSION) -- structural Protocols, runtime_checkable, nothing is forced to subclass
dazzle_lib.payloads The cross-layer TypedDict schemas: FileMetadataDict, TimestampsDict, WindowsMetadataDict, UnixMetadataDict, LinkTargetDict, HashResultDict -- mirroring what dazzle-filekit actually produces
dazzle_lib.exceptions DazzleError root + per-domain bases (PathIdentityError, FileOperationError, LinkError, PreserveError)
dazzle_lib.mixins DazzleDataMixin -- derives to_json/summary/__str__ from your to_dict

The idea: the dict is the interface

Rich objects in upper layers know how to become plain dicts; lower-layer functions take and return those dicts. The TypedDicts here are the agreed shapes, so a manifest object in dazzle-preservelib and a metadata collector in dazzle-filekit speak the same payload without sharing a class hierarchy:

from dataclasses import dataclass
from dazzle_lib import DazzleDataMixin, Serializable, FileMetadataDict

@dataclass
class TransferResult(DazzleDataMixin):
    SCHEMA_VERSION = 1
    path: str
    metadata: FileMetadataDict

    def to_dict(self):
        return {"schema_version": self.SCHEMA_VERSION,
                "path": self.path, "metadata": dict(self.metadata)}

    @classmethod
    def from_dict(cls, data):
        return cls(path=data["path"], metadata=data["metadata"])

result = TransferResult("a.txt", {"mode": 0o644, "size": 10, "timestamps": {}})
assert isinstance(result, Serializable)   # structural -- no subclassing needed
print(result.summary())                   # one-liner for logs

And one catchable root for the whole stack:

from dazzle_lib import DazzleError
try:
    ...  # any dazzle-* library call
except DazzleError as e:
    ...  # caught, whichever layer raised it

The charter (enforced by tests)

This package is stdlib-only forever and contains no behavior. tests/test_charter.py fails on any banned import (os, shutil, pathlib, subprocess, ...) anywhere in the package -- a PR that needs to weaken that test is adding something that belongs in a higher layer. Admission follows the rule of two: a Protocol or TypedDict enters the bedrock only when two or more stack libraries need it.

The stack

Layer Library Role
B dazzle-lib (this) bedrock contracts
L0 dazzle-unctools path identity (UNC/drive/origin)
L1 dazzle-filekit filesystem primitives
L2 dazzle-linklib (planned) link serialization
L3 dazzle-preservelib (planned) operation orchestration
dazzle-treelib traversal engine

Full architecture contract: STACK-MAP.md. API stability policy: docs/api-stability.md.

Development

pip install -e ".[dev]"
python -m pytest tests/ -v

License

MIT -- the bedrock sits beneath MIT and GPL stack members alike, so it carries the permissive license.

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

dazzle_lib-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

dazzle_lib-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file dazzle_lib-0.1.0.tar.gz.

File metadata

  • Download URL: dazzle_lib-0.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dazzle_lib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5364d2f2f9d090ac845e0778ff4603ae14c0af19c2141fca1dcb38a0bd770fcf
MD5 f1d97e64208f6d0b924b58d1fabc0e63
BLAKE2b-256 ca77053aa851f172c217e935b83a7849804ef1885c47bc6c1a72e9f609672ba5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dazzle_lib-0.1.0.tar.gz:

Publisher: release.yml on DazzleLib/dazzle-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dazzle_lib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dazzle_lib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dazzle_lib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 307b5acb512167b5a0db654eb552f37db9ca76d055f164a574ad4a8ba69806b0
MD5 7aeab2fa1fe25de1f04362bdcdccca8e
BLAKE2b-256 60ed85f5a358e6f54a0f1425cb21e8dae85cd2d11a76d5cc81e55d3cd8cf3622

See more details on using hashes here.

Provenance

The following attestation bundles were made for dazzle_lib-0.1.0-py3-none-any.whl:

Publisher: release.yml on DazzleLib/dazzle-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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