Skip to content

Commit 490c203

Browse files
authored
Merge pull request #303 from tmux-python/diagnostics
Diagnostics: MK1
2 parents aa363c6 + 0be7670 commit 490c203

File tree

9 files changed

+34
-15
lines changed

9 files changed

+34
-15
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Here you can find the recent changes to libtmux
66

77
current
88
-------
9+
- :issue:`303` Add ``common.get_libtmux_version`` which gives the tmux
10+
version as a loose constraint. Fix linking to terms inside docs, and
11+
duplicate description of module which sphinx warned about in api.rst.
912
- *Insert changes/features/fixes for next release here*
1013

1114
libtmux 0.8.4 (2020-10-25)

docs/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Internals
8686

8787
.. automethod:: libtmux.common.handle_option_error
8888

89+
.. automethod:: libtmux.common.get_libtmux_version
90+
8991
Exceptions
9092
----------
9193

libtmux/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# flake8: NOQA
3-
"""API for interfacing with tmux servers, sessions, windows and panes.
4-
5-
libtmux
6-
~~~~~~~
7-
8-
:copyright: Copyright 2016-2018 Tony Narlock.
9-
:license: MIT, see LICENSE for details
10-
11-
"""
12-
133
from .__about__ import (
144
__author__,
155
__copyright__,

libtmux/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,16 @@ def handle_option_error(error):
668668
raise exc.AmbiguousOption(error)
669669
else:
670670
raise exc.OptionError(error) # Raise generic option error
671+
672+
673+
def get_libtmux_version():
674+
"""Return libtmux version is a PEP386 compliant format.
675+
676+
Returns
677+
-------
678+
distutils.version.LooseVersion
679+
libtmux version
680+
"""
681+
from libtmux.__about__ import __version__
682+
683+
return LooseVersion(__version__)

libtmux/pane.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class Pane(TmuxMappingObject, TmuxRelationalObject):
2020
"""
21-
A :term:`tmux(1)` :term:`pane` [#]_.
21+
A :term:`tmux(1)` :term:`Pane` [#]_.
2222
2323
``Pane`` instances can send commands directly to a pane, or traverse
2424
between linked tmux objects.
@@ -155,7 +155,9 @@ def reset(self):
155155

156156
self.cmd('send-keys', r'-R \; clear-history')
157157

158-
def split_window(self, attach=False, vertical=True, start_directory=None, percent=None):
158+
def split_window(
159+
self, attach=False, vertical=True, start_directory=None, percent=None
160+
):
159161
"""
160162
Split window at pane and return newly created :class:`Pane`.
161163

libtmux/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class Server(TmuxRelationalObject, EnvironmentMixin):
2727

2828
"""
29-
The :term:`tmux(1)` :term:`server` [#]_.
29+
The :term:`tmux(1)` :term:`Server` [#]_.
3030
3131
- :attr:`Server._sessions` [:class:`Session`, ...]
3232

libtmux/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class Session(TmuxMappingObject, TmuxRelationalObject, EnvironmentMixin):
2929
"""
30-
A :term:`tmux(1)` :term:`session` [#]_.
30+
A :term:`tmux(1)` :term:`Session` [#]_.
3131
3232
Holds :class:`Window` objects.
3333

libtmux/window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class Window(TmuxMappingObject, TmuxRelationalObject):
2222
"""
23-
A :term:`tmux(1)` :term:`window` [#]_.
23+
A :term:`tmux(1)` :term:`Window` [#]_.
2424
2525
Holds :class:`Pane` objects.
2626

tests/test_common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from libtmux.common import (
1212
TMUX_MAX_VERSION,
1313
TMUX_MIN_VERSION,
14+
get_libtmux_version,
1415
get_version,
1516
has_gt_version,
1617
has_gte_version,
@@ -201,3 +202,11 @@ def test_session_check_name(session_name, raises, exc_msg_regex):
201202
assert exc_info.match(exc_msg_regex)
202203
else:
203204
session_check_name(session_name)
205+
206+
207+
def test_get_libtmux_version():
208+
from libtmux.__about__ import __version__
209+
210+
version = get_libtmux_version()
211+
assert isinstance(version, LooseVersion)
212+
assert LooseVersion(__version__) == version

0 commit comments

Comments
 (0)