nat.utils.string_utils#

Functions#

convert_to_str(→ str)

Convert a value to a string representation.

truncate_string(→ str | None)

Truncate a string to a maximum length, adding ellipsis if truncated.

Module Contents#

convert_to_str(value: Any) str#

Convert a value to a string representation. Handles various types including lists, dictionaries, and other objects.

truncate_string(text: str | None, max_length: int = 100) str | None#

Truncate a string to a maximum length, adding ellipsis if truncated.

Args:

text: The text to truncate (can be None) max_length: Maximum allowed length (default: 100)

Returns:

The truncated text with ellipsis if needed, or None if input was None