Module

services.utils

Shared utilities for the services package.

Consolidates common patterns used across service modules:

  • Package directory resolution (get_bengal_dir)
  • Immutable data structures (freeze_dict, freeze_value)
  • Collection helpers (find_first)

These utilities support the snapshot-enabled architecture where services operate on immutable data structures.

Functions

get_bengal_dir 0 Path
Get the bengal package root directory (cached).
def get_bengal_dir() -> Path
Returns
Path
get_bundled_themes_dir 0 Path
Get the directory containing bundled themes.
def get_bundled_themes_dir() -> Path
Returns
Path
freeze_dict 1 MappingProxyType[str, An…
Recursively freeze a dictionary. **Converts:** - dict → MappingProxyType (immu…
def freeze_dict(d: dict[str, Any]) -> MappingProxyType[str, Any]

Recursively freeze a dictionary.

Converts:

  • dict → MappingProxyType (immutable view)
  • list → tuple (immutable sequence)
Parameters
Name Type Description
d dict[str, Any]

Dictionary to freeze

Returns
MappingProxyType[str, Any]
freeze_value 1 Any
Freeze a single value. **Converts:** - dict → MappingProxyType - list → tuple …
def freeze_value(item: Any) -> Any

Freeze a single value.

Converts:

  • dict → MappingProxyType
  • list → tuple (with nested values frozen)
  • Other values returned unchanged
Parameters
Name Type Description
item Any

Value to freeze

Returns
Any