euporie.core.convert.utils
Utility functions for format converters.
Functions
|
Call the command as a subprocess and return it's output as bytes. |
|
Verify a list of external commands exist on the system. |
|
Convert between formats. |
|
Get the dimensions of an image. |
|
Get the current active (running) Application. |
|
Verify a list of python modules are importable. |
|
Import a module. |
|
Get the cell width and aspect ration of a pixel dimension. |
|
Apply a function of two arguments cumulatively to the items of a sequence or iterable, from left to right, so as to reduce the iterable to a single value. |
|
Accept both booleans and Filters as input and turn it into a Filter. |
|
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. |
Classes
|
Turn any callable into a Filter. |
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
- async euporie.core.convert.utils.call_subproc(data: str | bytes, cmd: list[Any], use_tempfile: bool = False, suffix: str = '') bytes
Call the command as a subprocess and return it’s output as bytes.
- Parameters
data – The data to pass to the subprocess
cmd – The command and arguments to call
use_tempfile – If True, the command saves its output to a file, not stdout
suffix – Suffix for the temporary file name
- Returns
The data printed to standard out by the subprocess.
- euporie.core.convert.utils.commands_exist(*cmds: str) Filter
Verify a list of external commands exist on the system.
- euporie.core.convert.utils.data_pixel_size(data: Any, format_: str, fg: str | None = None, bg: str | None = None) tuple[int | None, int | None]
Get the dimensions of an image.
Foreground and background color are set at this point if they are available, as data conversion outputs are cached and re-used.
- Parameters
data – The data to check the dimensions of
format – The current format of the data
fg – The desired foreground color of the data
bg – The desired background color of the data
- Returns
- A tuple of the data’s width in terminal columns and its aspect ratio, when
converted to a image.
- euporie.core.convert.utils.have_modules(*modules: str) Filter
Verify a list of python modules are importable.
- euporie.core.convert.utils.pixels_to_cell_size(px: int | None = None, py: int | None = None) tuple[int, float]
Get the cell width and aspect ration of a pixel dimension.
- Parameters
px – The desired pixel width of the data if known
py – The pixel height of the data if known
- Returns
- A tuple of the data’s width in terminal columns and its aspect ratio, when
converted to a image.