euporie.core.convert.core

Contain main format conversion function.

Functions

NamedTuple(typename[, fields])

Typed version of namedtuple.

convert(data, from_, to[, cols, rows, fg, ...])

Convert between formats.

find_route(from_, to)

Find the shortest conversion path between two formats.

get_format(path[, default])

Attempt to guess the format of a path.

get_loop()

Create or return the conversion IO loop.

get_mime(path)

Attempt to determine the mime-type of a path.

lru_cache([maxsize, typed])

Least-recently-used cache decorator.

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.

DataPath(*args, **kwargs)

A pathlib compatible class for reading data URIs.

FastDictCache(get_value[, size])

Fast, lightweight cache which keeps at most size items.

HTTPPath(*args, **kwargs)

SimpleCache([maxsize])

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

UPath(*args, **kwargs)

class euporie.core.convert.core.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.core.convert(data: Any, from_: str, to: str, cols: int | None = None, rows: int | None = None, fg: str | None = None, bg: str | None = None, path: Path | None = None) Any | None

Convert between formats.

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

Find the shortest conversion path between two formats.

euporie.core.convert.core.get_format(path: Path | str, default: str = '') str

Attempt to guess the format of a path.

euporie.core.convert.core.get_loop() asyncio.events.AbstractEventLoop

Create or return the conversion IO loop.

The loop will be running on a separate thread.

euporie.core.convert.core.get_mime(path: Path | str) str | None

Attempt to determine the mime-type of a path.

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

Add a converter to the centralized format conversion system.