Skip to main content

toolbox-py

A comprehensive collection of Python utilities for everyday programming tasks.

Features

Dictionary Utilities (toolbox.dict)

  • DotDict: Dictionary with dot notation access
  • flatten_dict: Flatten nested dictionaries with customizable separators
  • unflatten_dict: Convert flattened dicts back to nested structure
  • merge_dicts: Recursively merge dictionaries
  • get_nested/set_nested: Access nested values using dot notation paths
  • filter_dict: Filter dictionaries with predicate functions
  • invert_dict: Swap keys and values
  • deep_copy_dict: Deep copy nested dictionaries

List Utilities (toolbox.list)

  • flatten_list: Recursively flatten nested lists
  • chunk_list: Split lists into fixed-size chunks
  • unique: Remove duplicates while preserving order
  • partition: Split lists based on predicate
  • group_by: Group items by key function
  • dedupe: Advanced deduplication with custom key functions
  • interleave: Merge multiple lists element by element
  • compact: Remove falsy values (None, '', False, etc.)

String Utilities (toolbox.string)

  • Case conversion: camel_to_snake, snake_to_camel, kebab_case, title_case
  • Compression: compress_string/decompress_string with base64 encoding
  • Formatting: slugify, truncate, wrap_text
  • Text processing: remove_accents, strip_html, reverse_string, count_words

Encoding/Decoding (toolbox.encode, toolbox.decode)

  • Base64 encoding and decoding
  • Support for both str and bytes

Data Serialization (toolbox.dataclass)

  • SerializableDataclass: Enhanced dataclass with JSON serialization
  • Alias support for field name mapping
  • Preprocessors for data transformation
  • Nested dataclass handling

Installation

pip install toolbox-py

Or with uv:

uv add toolbox-py

Usage Examples

Dictionary Operations

from toolbox.dict import flatten_dict, get_nested, DotDict

# Flatten nested dictionary
nested = {'user': {'name': 'John', 'address': {'city': 'NYC'}}}
flat = flatten_dict(nested)
# {'user.name': 'John', 'user.address.city': 'NYC'}

# Access nested values safely
city = get_nested(nested, 'user.address.city', default='Unknown')

# Dot notation access
config = DotDict({'database': {'host': 'localhost'}})
print(config.database.host)  # localhost

List Operations

from toolbox.list import chunk_list, group_by, dedupe

# Split into chunks
items = [1, 2, 3, 4, 5, 6, 7]
chunks = chunk_list(items, 3)  # [[1, 2, 3], [4, 5, 6], [7]]

# Group by key
words = ['apple', 'apricot', 'banana', 'blueberry']
by_first = group_by(words, lambda w: w[0])
# {'a': ['apple', 'apricot'], 'b': ['banana', 'blueberry']}

# Deduplicate with custom key
users = [{'id': 1, 'name': 'Alice'}, {'id': 1, 'name': 'Bob'}]
unique_users = dedupe(users, key=lambda u: u['id'])

String Operations

from toolbox.string import slugify, truncate, camel_to_snake

# Create URL-friendly slugs
slug = slugify('Hello World!')  # 'hello-world'

# Truncate with ellipsis
text = truncate('Long text here', 10)  # 'Long te...'

# Convert naming conventions
snake = camel_to_snake('CamelCase')  # 'camel_case'

Development

# Setup environment
uv sync

# Run tests
pytest

# Format code
black toolbox/ tests/
isort toolbox/ tests/

# Type check
mypy toolbox/

# Build docs
cd docs && make html

Requirements

  • Python >= 3.11

License

MIT License - see LICENSE file for details

Metadata

Release files for sadtech-kit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sadtech-kit 0.1.0
File Size Uploaded
sadtech_kit-0.1.0.tar.gz 34.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sadtech-kit 0.1.0
File Interpreter ABI Platform
sadtech_kit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / sadtech_kit-0.1.0.tar.gz

Download URL sadtech_kit-0.1.0.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aff9a66e0831f292157d0470f819e05feebe4203920608d8bfd17ab72927fe3f
BLAKE2b-256 checksum
How to use checksums
8d454de54f0abc2cf73171cf7f730db0d3dbe6a9c07b61c86e53de8de8d09440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sadtech_kit-0.1.0-py3-none-any.whl

Download URL sadtech_kit-0.1.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
503b9aa8dee69d5a6c849f9906c4c9efeaf041706e52ab9f16f1f17360b8e6c3
BLAKE2b-256 checksum
How to use checksums
e38609fb1e73440c23dc9affdba954a9f20079aaecf5f8798d044dd680fa02f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page