parse_output
Parse a tmux -F line into a dict keyed by Obj field name.
Source and package
- Qualified name
-
libtmux.neo .parse _output - Module
- libtmux.neo
- Package
- libtmux
- Source
- src/libtmux/neo.py
-
Description#
The (list_cmd, tmux_version) pair must match what was passed to
get_output_formatwhen the-Ftemplate was built — otherwise the field order won't line up with the split values.Examples#
>>> from libtmux.neo import get_output_format, parse_output>>> from libtmux.formats import FORMAT_SEPARATOR>>> fields, fmt = get_output_format("list-sessions", "3.6a")>>> values = [''] * len(fields)>>> values[fields.index('session_id')] = '$1'>>> result = parse_output(... FORMAT_SEPARATOR.join(values) + FORMAT_SEPARATOR,... list_cmd="list-sessions",... tmux_version="3.6a",... )>>> result['session_id']'$1'>>> 'pane_id' in resultFalse- Parameters
-
-
output(str) # – Raw tmux output line produced with a template fromget_output_format. -
list_cmd(str) # – Same value passed toget_output_format. -
tmux_version(str) # – Same value passed toget_output_format.
-
- Returns
-
OutputRaw A dict mapping field names to non-empty string values.