euporie.core.convert.registry

Contain main format conversion function.

Functions

NamedTuple(typename[, fields])

Typed version of namedtuple.

find_route(from_, to)

Find and cache conversion routes.

register(from_, to[, filter_, weight])

Add a converter to the centralized format conversion system.

to_filter(bool_or_filter)

Accept both booleans and Filters as input and turn it into a Filter.

Classes

Converter(func, filter_[, weight])

Hold a conversion function and its weight.

FastDictCache(get_value[, size])

Fast, lightweight cache which keeps at most size items.

SimpleCache([maxsize])

Very simple cache that discards the oldest item when the cache size is exceeded.

class euporie.core.convert.registry.Converter(func: Callable, filter_: Filter, weight: int = 1)

Bases: NamedTuple

Hold a conversion function and its weight.

count(value, /)

Return number of occurrences of value.

filter_: Filter

Alias for field number 1

func: Callable

Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

weight: int

Alias for field number 2

euporie.core.convert.registry.find_route(from_: str, to: str) list | None

Find and cache conversion routes.

euporie.core.convert.registry.register(from_: Iterable[str] | str, to: str, filter_: FilterOrBool = True, weight: int = 1) Callable

Add a converter to the centralized format conversion system.