Skip to content

Diagnostics: MK1 #303

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

Merged
merged 6 commits into from
Oct 25, 2020
Merged
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: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Here you can find the recent changes to libtmux

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

libtmux 0.8.4 (2020-10-25)
Expand Down
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Internals

.. automethod:: libtmux.common.handle_option_error

.. automethod:: libtmux.common.get_libtmux_version

Exceptions
----------

Expand Down
10 changes: 0 additions & 10 deletions libtmux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# -*- coding: utf-8 -*-
# flake8: NOQA
"""API for interfacing with tmux servers, sessions, windows and panes.

libtmux
~~~~~~~

:copyright: Copyright 2016-2018 Tony Narlock.
:license: MIT, see LICENSE for details

"""

from .__about__ import (
__author__,
__copyright__,
Expand Down
13 changes: 13 additions & 0 deletions libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,16 @@ def handle_option_error(error):
raise exc.AmbiguousOption(error)
else:
raise exc.OptionError(error) # Raise generic option error


def get_libtmux_version():
"""Return libtmux version is a PEP386 compliant format.

Returns
-------
distutils.version.LooseVersion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pypa/distutils#19 This is where i'd like to link to LooseVersion

libtmux version
"""
from libtmux.__about__ import __version__

return LooseVersion(__version__)
6 changes: 4 additions & 2 deletions libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class Pane(TmuxMappingObject, TmuxRelationalObject):
"""
A :term:`tmux(1)` :term:`pane` [#]_.
A :term:`tmux(1)` :term:`Pane` [#]_.

``Pane`` instances can send commands directly to a pane, or traverse
between linked tmux objects.
Expand Down Expand Up @@ -155,7 +155,9 @@ def reset(self):

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

def split_window(self, attach=False, vertical=True, start_directory=None, percent=None):
def split_window(
self, attach=False, vertical=True, start_directory=None, percent=None
):
"""
Split window at pane and return newly created :class:`Pane`.

Expand Down
2 changes: 1 addition & 1 deletion libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class Server(TmuxRelationalObject, EnvironmentMixin):

"""
The :term:`tmux(1)` :term:`server` [#]_.
The :term:`tmux(1)` :term:`Server` [#]_.

- :attr:`Server._sessions` [:class:`Session`, ...]

Expand Down
2 changes: 1 addition & 1 deletion libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class Session(TmuxMappingObject, TmuxRelationalObject, EnvironmentMixin):
"""
A :term:`tmux(1)` :term:`session` [#]_.
A :term:`tmux(1)` :term:`Session` [#]_.

Holds :class:`Window` objects.

Expand Down
2 changes: 1 addition & 1 deletion libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class Window(TmuxMappingObject, TmuxRelationalObject):
"""
A :term:`tmux(1)` :term:`window` [#]_.
A :term:`tmux(1)` :term:`Window` [#]_.

Holds :class:`Pane` objects.

Expand Down
9 changes: 9 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from libtmux.common import (
TMUX_MAX_VERSION,
TMUX_MIN_VERSION,
get_libtmux_version,
get_version,
has_gt_version,
has_gte_version,
Expand Down Expand Up @@ -201,3 +202,11 @@ def test_session_check_name(session_name, raises, exc_msg_regex):
assert exc_info.match(exc_msg_regex)
else:
session_check_name(session_name)


def test_get_libtmux_version():
from libtmux.__about__ import __version__

version = get_libtmux_version()
assert isinstance(version, LooseVersion)
assert LooseVersion(__version__) == version