From: Michael Tremer Date: Wed, 22 Jan 2025 17:27:06 +0000 (+0000) Subject: distros: Make them sortable X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e25dca6794f146f82103d3bd5cdf2ec4787b71a;p=pbs.git distros: Make them sortable Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/distros.py b/src/buildservice/distros.py index afb0fc1e..8600e8d6 100644 --- a/src/buildservice/distros.py +++ b/src/buildservice/distros.py @@ -92,6 +92,12 @@ class Distros(base.Object): class Distro(database.Base, database.BackendMixin, database.SoftDeleteMixin): __tablename__ = "distributions" + def __lt__(self, other): + if isinstance(other, self.__class__): + return self.name < other.name or self.version < other.version + + return NotImplemented + def __str__(self): return "%s %s" % (self.name, self.version)