Coverage for daklib/aptversion.py: 83%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2026-01-04 16:18 +0000

1# Copyright (C) 2018, Ansgar Burchardt <ansgar@debian.org> 

2# License: GPL-2+ 

3# 

4# This program is free software; you can redistribute it and/or modify 

5# it under the terms of the GNU General Public License as published by 

6# the Free Software Foundation; either version 2 of the License, or 

7# (at your option) any later version. 

8# 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU General Public License for more details. 

13# 

14# You should have received a copy of the GNU General Public License 

15# along with this program. If not, see <https://www.gnu.org/licenses/>. 

16 

17from typing import override 

18 

19import apt_pkg 

20 

21 

22class AptVersion: 

23 def __init__(self, version): 

24 self.version = version 

25 

26 @override 

27 def __str__(self): 

28 return str(self.version) 

29 

30 @override 

31 def __eq__(self, other): 

32 return apt_pkg.version_compare(self.version, other.version) == 0 

33 

34 def __lt__(self, other): 

35 return apt_pkg.version_compare(self.version, other.version) < 0 

36 

37 def __le__(self, other): 

38 return apt_pkg.version_compare(self.version, other.version) <= 0 

39 

40 def __gt__(self, other): 

41 return apt_pkg.version_compare(self.version, other.version) > 0 

42 

43 def __ge__(self, other): 

44 return apt_pkg.version_compare(self.version, other.version) >= 0