Skip to main content

Core utilities for Kat-based microservices

Project description

corekat-light

corekat is a powerful, asynchronous Python toolkit providing shared utilities for Kat-based microservices. It offers robust configuration management, pluggable file download capabilities, foundational async client infrastructure, and standardized exception handling.

Key Features

  • Type-Safe Configuration: Manage your application's settings with Pydantic V2, loading from YAML files and environment variables with a clear hierarchy.
  • Exception Hierarchy: Standardized exceptions with HTTP status mapping, structured error details, and automatic serialization.
  • String & Dict Utilities: Case conversion (to_snake_case, to_pascal_case, to_kebab_case) and dictionary flattening/unflattening for config transformations.
  • Pluggable Download Client: A fully asynchronous DownloadClient for handling files from HTTP, local storage, and S3 (via StashKat) through a pluggable "fetcher" protocol.
  • Dependency Injection Pattern: Encourages clean architecture by promoting dependency injection for configuration and clients, making your code more modular and easier to test.
  • Async Context Managers: All clients support async with for automatic resource cleanup.

What's New in v3

Exception Hierarchy

Standardized exception handling with automatic HTTP status mapping:

from corekat.exceptions import NotFoundError, ValidationError

# Raise with structured details
raise NotFoundError(
    "User not found",
    details={"user_id": "123"}
)

# Automatic HTTP mapping in ServeKat
# → 404 response with {"code": "not_found", "message": "...", "details": {...}}

String Utilities

Common string transformations for code generation and API design:

from corekat import to_snake_case, to_pascal_case, to_kebab_case

to_snake_case("HelloWorld")    # "hello_world"
to_pascal_case("hello_world")  # "HelloWorld"
to_kebab_case("HelloWorld")    # "hello-world"

Dict Utilities

Flatten and unflatten nested dictionaries for config processing:

from corekat import flatten_dict, unflatten_dict

nested = {"app": {"db": {"host": "localhost"}}}
flat = flatten_dict(nested)
# {"app.db.host": "localhost"}

restored = unflatten_dict(flat)
# {"app": {"db": {"host": "localhost"}}}

Installation

Install the library and its dependencies.

# Core library
uv pip install corekat

# For S3 support, install the stashkat plugin
uv pip install stashkat

# For development with all extras
uv pip install -e ".[dev,all]"

(Requires Python >= 3.12)

Full Documentation

For detailed guides, tutorials, and the API reference, please visit the full documentation site.

Development

  • Setup: uv sync --dev
  • Testing: make test
  • Linting & Formatting: make check and make fix

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

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

corekat-0.3.3.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

corekat-0.3.3-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file corekat-0.3.3.tar.gz.

File metadata

  • Download URL: corekat-0.3.3.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for corekat-0.3.3.tar.gz
Algorithm Hash digest
SHA256 b714cd1f6ee75b06786b9af2f13a9ab41e88c24756bf7a9e5edb827e10a2056e
MD5 a4c3ce91f136c26d5cadec70045ab464
BLAKE2b-256 d91d4691c45a737d2b2a341478034ea41a0e770be4c560a3e1d8694b781769d3

See more details on using hashes here.

File details

Details for the file corekat-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: corekat-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for corekat-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8cd73dbcaeec84ef7297dc9544b6be8351e2f86d42752e81866c9e13d6d96a4
MD5 a28fe67160e068b8bab228b9b4b1e0c2
BLAKE2b-256 2100b4cbdcf68fc97400bc351d01bfdeff6b7f5fd37526a39030b6e6c1c9e347

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