mixing.egress¶
Canonical egress: route a produced result to its destination.
Across mixing, every result-producing function takes a single output
parameter whose role is constant — “what to do with the result” — while its
type is open:
|
behavior |
|---|---|
|
return the in-memory result (object producers) or save next to the input (file producers); see below |
a file path |
write the result there; return the |
a directory |
write with an auto-derived name; return the |
a callable |
return |
There are two flavors of producer, modeled by two helpers:
deliver()— object-first:output=Nonereturns the in-memory object (e.g. anAudio). Used by editing functions that build a value you may want to keep chaining.write_egress()— file-first:output=Nonesaves to a default path (typically beside the input) and returns it. Used by file→file operations whose whole point is to produce a file.
Both accept the same output forms, so callers learn one mental model.
Output is the shared type alias.
Module Attributes
nothing, a filesystem path/dir, or a result-consuming sink. |
Functions
|
True if |
|
True if |
|
Resolve a path/dir |
|
Object-first egress: route an in-memory |
|
File-first egress: for operations whose primary effect is writing a file. |
- mixing.egress.Output¶
nothing, a filesystem path/dir, or a result-consuming sink.
- Type:
An egress target
alias of
None|str|os.PathLike[str]|Callable[[Any],Any]
- mixing.egress.deliver(result, output, *, write, default_name)[source]¶
Object-first egress: route an in-memory
resulttooutput.None→ returnresultunchanged (no I/O).sink callable → return
output(result).path/dir →
write(result, path)then return thePath.
- Parameters:
result (
Any) – the produced in-memory value (e.g. anAudio).output (
Union[None,str,PathLike[str],Callable[[Any],Any]]) – the egress target (see module docstring).write (
Callable[[Any,Path],Any]) –write(result, path)persistsresulttopath.default_name (
str) – filename to use whenoutputis a directory.
- Return type:
- mixing.egress.is_path_output(output)[source]¶
True if
outputdenotes a filesystem path (str/os.PathLike).- Return type:
- mixing.egress.is_sink(output)[source]¶
True if
outputis a result-consuming callable (not a path).- Return type:
- mixing.egress.resolve_output_path(output, *, default_name)[source]¶
Resolve a path/dir
outputto a concrete filePath(parents created).A directory
output(existing, or with a trailing separator) is joined withdefault_name. Only call this whenoutputis a path — notNoneand not a sink.- Return type:
- mixing.egress.write_egress(output, *, default_path, write)[source]¶
File-first egress: for operations whose primary effect is writing a file.
None→ write todefault_path(e.g. beside the input) and return it.sink callable → write to
default_path, then returnoutput(path).path/dir → write to that file (dir →
default_path’s name inside it).
- Parameters:
output (
Union[None,str,PathLike[str],Callable[[Any],Any]]) – the egress target (see module docstring).default_path (
Union[str,PathLike[str]]) – where to write whenoutputisNone/ a sink, and the source of the auto filename whenoutputis a directory.write (
Callable[[Path],Any]) –write(path)performs the actual encode topath.
- Return type: