From cdfd8f20ed85063390ccc55589250c813c337658 Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Thu, 21 Apr 2022 10:05:35 +0300 Subject: [PATCH] Add a shortcut to obtain the instance of a possibly existing cnfvar This is added in the cnf list query mixin which is where we have all shortcut, syntactic sugar, and ease of use methods. --- src/cnfvar/model.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/cnfvar/model.py b/src/cnfvar/model.py index 827ff99..168f5db 100644 --- a/src/cnfvar/model.py +++ b/src/cnfvar/model.py @@ -929,6 +929,10 @@ class CnfListQueryingMixin(BaseCnfList): """Shortcut method for getting the first item with a given instance.""" return self.with_instance(instance).first(default=default) + def highest_instance(self): + """Shortcut method for getting the next instance in a list of items.""" + return max([c.instance for c in self]) if len(self) > 0 else -1 + ############################################################################### # PUBLIC CLASSES -- 1.7.1