Utils
natal.utils
utility functions for natal
color_hex(name: str, config: Config = Config()) -> str
member_of(const: list[T], name: str) -> T
Get a member from a list of constants by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
const
|
list[T]
|
List of constant definitions |
required |
name
|
str
|
Name to look up |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
Matching constant member |
Source code in natal/utils.py
pairs(iterable: Iterable[T]) -> list[tuple[T, T]]
Generate unique pairs of elements from an iterable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable
|
Iterable[T]
|
Source of elements to pair |
required |
Returns:
Type | Description |
---|---|
list[tuple[T, T]]
|
list[tuple[T, T]]: List of element pairs as tuples |
Source code in natal/utils.py
str_to_dt(dt_str: str) -> datetime
Convert string to datetime object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt_str
|
str
|
Datetime string in format "YYYY-MM-DD HH:MM" |
required |
Returns:
Name | Type | Description |
---|---|---|
datetime |
datetime
|
Parsed datetime object |