Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/zmq/sugar/version.py: 75%

24 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-01 06:54 +0000

1"""PyZMQ and 0MQ version functions.""" 

2 

3# Copyright (C) PyZMQ Developers 

4# Distributed under the terms of the Modified BSD License. 

5 

6import re 

7from typing import Match, Tuple, Union, cast 

8 

9from zmq.backend import zmq_version_info 

10 

11__version__: str = "25.1.0" 

12_version_pat = re.compile(r"(\d+)\.(\d+)\.(\d+)(.*)") 

13_match = cast(Match, _version_pat.match(__version__)) 

14_version_groups = _match.groups() 

15 

16VERSION_MAJOR = int(_version_groups[0]) 

17VERSION_MINOR = int(_version_groups[1]) 

18VERSION_PATCH = int(_version_groups[2]) 

19VERSION_EXTRA = _version_groups[3].lstrip(".") 

20 

21version_info: Union[Tuple[int, int, int], Tuple[int, int, int, float]] = ( 

22 VERSION_MAJOR, 

23 VERSION_MINOR, 

24 VERSION_PATCH, 

25) 

26 

27if VERSION_EXTRA: 

28 version_info = ( 

29 VERSION_MAJOR, 

30 VERSION_MINOR, 

31 VERSION_PATCH, 

32 float('inf'), 

33 ) 

34 

35__revision__: str = '' 

36 

37 

38def pyzmq_version() -> str: 

39 """return the version of pyzmq as a string""" 

40 if __revision__: 

41 return '+'.join([__version__, __revision__[:6]]) 

42 else: 

43 return __version__ 

44 

45 

46def pyzmq_version_info() -> Union[Tuple[int, int, int], Tuple[int, int, int, float]]: 

47 """return the pyzmq version as a tuple of at least three numbers 

48 

49 If pyzmq is a development version, `inf` will be appended after the third integer. 

50 """ 

51 return version_info 

52 

53 

54def zmq_version() -> str: 

55 """return the version of libzmq as a string""" 

56 return "%i.%i.%i" % zmq_version_info() 

57 

58 

59__all__ = [ 

60 'zmq_version', 

61 'zmq_version_info', 

62 'pyzmq_version', 

63 'pyzmq_version_info', 

64 '__version__', 

65 '__revision__', 

66]