From: Plamen Dimitrov Date: Thu, 21 Apr 2022 07:05:35 +0000 (+0300) Subject: Add a shortcut to obtain the instance of a possibly existing cnfvar X-Git-Tag: v1.7.1~4^2~6 X-Git-Url: http://developer.intra2net.com/git/?p=pyi2ncommon;a=commitdiff_plain;h=cdfd8f20ed85063390ccc55589250c813c337658 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. --- 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