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.2.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.2-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: corekat-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 f60c31cd01c87bfa60dac0bd0949a8c1229ee14442fd35dac1ee7a3d23ad7ebb
MD5 537b1a7d7bf57c0ca71a4f83bff8f93f
BLAKE2b-256 39c0209a48e95464c53aeb6eb8530a100f4c40f198de7e16f52cc11467a0d4fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: corekat-0.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb7477c5748096beac59ca4043a09d3d9cfcc7078d56902d36181d7bc41ee49b
MD5 275a72f7d7bdefcb63928afe9422df31
BLAKE2b-256 75d86001d4c6f472f8cc4e55e4d9e2cdd3e3f2eba87ff502640dcfaf4a224219

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