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 

17import apt_pkg 

18 

19 

20class AptVersion: 

21 def __init__(self, version): 

22 self.version = version 

23 

24 def __str__(self): 

25 return str(self.version) 

26 

27 def __eq__(self, other): 

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

29 

30 def __lt__(self, other): 

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

32 

33 def __le__(self, other): 

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

35 

36 def __gt__(self, other): 

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

38 

39 def __ge__(self, other): 

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