Genro-Toolbox Logo

Genro-Toolbox

Essential utilities for the Genro ecosystem (Genro Kyō)

Genro-Toolbox is a lightweight, zero-dependency Python library providing core utilities for Genro Kyō (genro-asgi, genro-routes, genro-api, etc.). Think of it as the foundation from which Genro solutions are built.

Features

  • SmartOptions - Intelligent options merging with filtering and defaults

  • TreeDict - Hierarchical dictionary with dot notation path access

  • DictObj - Dict subclass with dot-access for attribute-style read/write

  • extract_kwargs - Decorator for extracting and grouping keyword arguments by prefix

  • dictExtract - Extract dict items by key prefix

  • smartsplit - Split strings honoring escaped separators

  • tags_match - Boolean expression matcher for tag-based filtering

  • get_uuid - Sortable 22-char unique identifiers for distributed systems

  • smartasync - Unified sync/async API decorator with automatic context detection

  • smarttimer - Non-blocking timers (set_timeout/set_interval) with sync/async detection

  • safe_is_instance - Type checking without imports

  • ascii_table - Beautiful ASCII and Markdown tables with formatting and hierarchies

  • Zero dependencies - Pure Python standard library only (optional: tomli, pyyaml)

  • Full type hints - Complete typing support

  • Python 3.10+ - Modern Python

Quick Example

from genro_toolbox import extract_kwargs

@extract_kwargs(logging=True, cache=True)
def setup_service(name, logging_kwargs=None, cache_kwargs=None, **kwargs):
    print(f"Logging config: {logging_kwargs}")
    print(f"Cache config: {cache_kwargs}")

# All these styles work:
setup_service(
    name="api",
    logging_level="INFO",      # → logging_kwargs={'level': 'INFO'}
    cache_ttl=300,             # → cache_kwargs={'ttl': 300}
)

setup_service(
    name="api",
    logging={'level': 'INFO'},  # Dict style
    cache=True                  # Boolean activation
)

Part of Genro Kyō

Genro-Toolbox is part of Genro Kyō.

License

Apache License 2.0 - Copyright © 2025 Softwell Srl