Skip to content

fix: use | instead of \t for format sepatator #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.x"]
python-version: ["3.9"]
steps:
- uses: actions/checkout@v1
- name: Configure git
Expand Down Expand Up @@ -98,7 +98,6 @@ jobs:
run: poetry install --extras "docs lint"

- name: Build documentation
if: env.PUBLISH == 'true'
if: env.PUBLISH == 'true'
run: |
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd
Expand Down
6 changes: 5 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Here you can find the recent changes to libtmux
## current

- _Insert changes/features/fixes for next release here_

## libtmux 0.10.2 (2021-10-30)

- #324: Update poetry to 1.1
- CI: Use poetry 1.1.7 and `install-poetry.py` installer
- Relock poetry.lock at 1.1 (w/ 1.1.7's fix)
- #339 (CI): Lock python at 3.9 to avoid poetry issue with `dataclasses`
- ci: Fix publishing docs (similar to #339)
- #341 #342: `Server.attached_sessions()` now supports multiple attached sessions.

Remove attached sessions limitation to not detect multiple attached clients,
thank you @Timoses
thank you @timoses

## libtmux 0.10.1 (2021-06-16)
- Update `Window.select_window()` for #271
Expand Down
2 changes: 1 addition & 1 deletion libtmux/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'libtmux'
__package_name__ = 'libtmux'
__version__ = '0.10.1'
__version__ = '0.10.2'
__description__ = 'scripting library / orm for tmux'
__email__ = '[email protected]'
__author__ = 'Tony Narlock'
Expand Down
4 changes: 4 additions & 0 deletions libtmux/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

"""

from __future__ import absolute_import, unicode_literals, with_statement

FORMAT_SEPERATOR = "|"

SESSION_FORMATS = [
'session_name',
'session_windows',
Expand Down
53 changes: 45 additions & 8 deletions libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def _list_sessions(self):
sformats = formats.SESSION_FORMATS
tmux_formats = ['#{%s}' % f for f in sformats]

tmux_args = ('-F%s' % '\t'.join(tmux_formats),) # output
tmux_args = (
'-F%s' % formats.FORMAT_SEPERATOR.join(tmux_formats),
) # output

proc = self.cmd('list-sessions', *tmux_args)

Expand All @@ -154,7 +156,17 @@ def _list_sessions(self):
sessions = proc.stdout

# combine format keys with values returned from ``tmux list-sessions``
sessions = [dict(zip(sformats, session.split('\t'))) for session in sessions]
sessions = [
dict(
zip(
sformats,
session.split(
formats.FORMAT_SEPERATOR
)
)
)
for session in sessions
]

# clear up empty dict
sessions = [
Expand Down Expand Up @@ -207,7 +219,9 @@ def _list_windows(self):
proc = self.cmd(
'list-windows', # ``tmux list-windows``
'-a',
'-F%s' % '\t'.join(tmux_formats), # output
'-F%s' % formats.FORMAT_SEPERATOR.join(
tmux_formats
), # output
)

if proc.stderr:
Expand All @@ -218,7 +232,17 @@ def _list_windows(self):
wformats = ['session_name', 'session_id'] + formats.WINDOW_FORMATS

# combine format keys with values returned from ``tmux list-windows``
windows = [dict(zip(wformats, window.split('\t'))) for window in windows]
windows = [
dict(
zip(
wformats,
window.split(
formats.FORMAT_SEPERATOR
)
)
)
for window in windows
]

# clear up empty dict
windows = [dict((k, v) for k, v in window.items() if v) for window in windows]
Expand Down Expand Up @@ -267,7 +291,10 @@ def _list_panes(self):
'window_id',
'window_name',
] + formats.PANE_FORMATS
tmux_formats = ['#{%s}\t' % f for f in pformats]
tmux_formats = [
('#{%%s}%s' % formats.FORMAT_SEPERATOR) % f
for f in pformats
]

proc = self.cmd('list-panes', '-a', '-F%s' % ''.join(tmux_formats)) # output

Expand All @@ -285,7 +312,17 @@ def _list_panes(self):
] + formats.PANE_FORMATS

# combine format keys with values returned from ``tmux list-panes``
panes = [dict(zip(pformats, window.split('\t'))) for window in panes]
panes = [
dict(
zip(
pformats,
window.split(
formats.FORMAT_SEPERATOR
)
)
)
for window in panes
]

# clear up empty dict
panes = [
Expand Down Expand Up @@ -526,7 +563,7 @@ def new_session(
tmux_args = (
'-s%s' % session_name,
'-P',
'-F%s' % '\t'.join(tmux_formats), # output
'-F%s' % formats.FORMAT_SEPERATOR.join(tmux_formats), # output
)

if not attach:
Expand Down Expand Up @@ -557,7 +594,7 @@ def new_session(
os.environ['TMUX'] = env

# combine format keys with values returned from ``tmux list-windows``
session = dict(zip(sformats, session.split('\t')))
session = dict(zip(sformats, session.split(formats.FORMAT_SEPERATOR)))

# clear up empty dict
session = dict((k, v) for k, v in session.items() if v)
Expand Down
13 changes: 11 additions & 2 deletions libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def new_window(
start_directory = os.path.expanduser(start_directory)
window_args += ('-c%s' % start_directory,)

window_args += ('-F"%s"' % '\t'.join(tmux_formats),) # output
window_args += (
'-F"%s"' % formats.FORMAT_SEPERATOR.join(tmux_formats),
) # output
if window_name:
window_args += ('-n%s' % window_name,)

Expand All @@ -237,7 +239,14 @@ def new_window(

window = proc.stdout[0]

window = dict(zip(wformats, window.split('\t')))
window = dict(
zip(
wformats,
window.split(
formats.FORMAT_SEPERATOR
)
)
)

# clear up empty dict
window = dict((k, v) for k, v in window.items() if v)
Expand Down
7 changes: 5 additions & 2 deletions libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,10 @@ def split_window(
'window_index',
'window_id',
] + formats.PANE_FORMATS
tmux_formats = ['#{%s}\t' % f for f in pformats]
tmux_formats = [
('#{%%s}%s' % formats.FORMAT_SEPERATOR) % f
for f in pformats
]

# '-t%s' % self.attached_pane.get('pane_id'),
# 2013-10-18 LOOK AT THIS, rm'd it..
Expand Down Expand Up @@ -478,7 +481,7 @@ def split_window(
else:
pane = pane.stdout[0]

pane = dict(zip(pformats, pane.split('\t')))
pane = dict(zip(pformats, pane.split(formats.FORMAT_SEPERATOR)))

# clear up empty dict
pane = dict((k, v) for k, v in pane.items() if v)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip-string-normalization = true

[tool.poetry]
name = "libtmux"
version = "0.10.1"
version = "0.10.2"
description = "scripting library / orm for tmux"
license = "MIT"
authors = ["Tony Narlock <[email protected]>"]
Expand Down