aptversion.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import apt_pkg
  17. class AptVersion:
  18. def __init__(self, version):
  19. self.version = version
  20. def __str__(self):
  21. return str(self.version)
  22. def __eq__(self, other):
  23. return apt_pkg.version_compare(self.version, other.version) == 0
  24. def __lt__(self, other):
  25. return apt_pkg.version_compare(self.version, other.version) < 0
  26. def __le__(self, other):
  27. return apt_pkg.version_compare(self.version, other.version) <= 0
  28. def __gt__(self, other):
  29. return apt_pkg.version_compare(self.version, other.version) > 0
  30. def __ge__(self, other):
  31. return apt_pkg.version_compare(self.version, other.version) >= 0