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 Release Date Python 3.9+ License: MIT Installs Platform

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), PathVariantResolver (variants(path) -- a path's alternative names, e.g. UNC <-> mapped drive) -- 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.

Contributing

Contributions welcome! Please open an issue or submit a pull request.

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

Before proposing additions, note the two house rules this package lives by:

  • The charter: types only -- no I/O, no path handling, no behavior (tests/test_charter.py enforces it; a PR that needs to weaken that test belongs in a higher layer)
  • The rule of two: a Protocol or TypedDict enters the bedrock only when two or more stack libraries need it
  • API changes follow docs/api-stability.md (locked surface, noisy-shim deprecation policy)

Like the project?

"Buy Me A Coffee"

License

This project is licensed under the MIT License - see the LICENSE file for details. 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.2.0.tar.gz (16.5 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.2.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dazzle_lib-0.2.0.tar.gz
  • Upload date:
  • Size: 16.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 61d4d55a621e9f50ccae2eed5ead850fccffe9e10015a03a3832223323d7f8c4
MD5 c39f755e2e7e64143a58c7edb9840272
BLAKE2b-256 0e55a8a3bea13c1e085b5972411e660243449c7d054b4b953b28de4165be590d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dazzle_lib-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: dazzle_lib-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2cac13d2aea317be2c4ad71a4e3f6eec43a749554a7bf165c599e49735f303e
MD5 e11aab5cd6cbd8d4bc4aa7c79d4136b1
BLAKE2b-256 5e8b8cab4218c424985df21a8ba9538b6d8df733c75df2a6dcc10c49bb532441

See more details on using hashes here.

Provenance

The following attestation bundles were made for dazzle_lib-0.2.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