Skip to content

Commit 5d17967

Browse files
committed
!squash more / remove this is not liked
1 parent 88bda47 commit 5d17967

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/tmuxp/plugin.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from packaging.version import Version
2-
31
import libtmux
4-
from libtmux.common import get_version
2+
from libtmux.common import Version, get_version
53

64
from .__about__ import __version__
75
from .exc import TmuxpPluginException

src/tmuxp/util.py

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import logging
88
import os
9+
import re
910
import shlex
1011
import subprocess
1112
import sys
@@ -19,6 +20,27 @@
1920

2021
PY2 = sys.version_info[0] == 2
2122

23+
version_component_re = re.compile(r"(\d+|[a-z]+|\.)")
24+
25+
26+
def get_version_tuple(version):
27+
"""
28+
Return a tuple of version numbers (e.g. (1, 2, 3)) from the version
29+
string (e.g. '1.2.3').
30+
Credit: Django, License: MIT
31+
https://github.com/django/django/blob/dc9deea/django/utils/version.py#L99
32+
"""
33+
version_numbers = []
34+
for item in version_component_re.split(version):
35+
if item and item != ".":
36+
try:
37+
component = int(item)
38+
except ValueError:
39+
break
40+
else:
41+
version_numbers.append(component)
42+
return tuple(version_numbers)
43+
2244

2345
def run_before_script(script_file, cwd=None):
2446
"""Function to wrap try/except for subprocess.check_call()."""

0 commit comments

Comments
 (0)