File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1
- from packaging .version import Version
2
-
3
1
import libtmux
4
- from libtmux .common import get_version
2
+ from libtmux .common import Version , get_version
5
3
6
4
from .__about__ import __version__
7
5
from .exc import TmuxpPluginException
Original file line number Diff line number Diff line change 6
6
"""
7
7
import logging
8
8
import os
9
+ import re
9
10
import shlex
10
11
import subprocess
11
12
import sys
19
20
20
21
PY2 = sys .version_info [0 ] == 2
21
22
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
+
22
44
23
45
def run_before_script (script_file , cwd = None ):
24
46
"""Function to wrap try/except for subprocess.check_call()."""
You can’t perform that action at this time.
0 commit comments