def truncated(f):
 @functools.wraps(f)
 def wrapper(self, hints, *args, **kwargs):
  if (not hasattr(hints, 'limit')):
   raise exception.UnexpectedError(_('Cannot truncate a driver call without hints list as first parameter after self '))
  if ((hints.limit is None) or hints.filters):
   return f(self, hints, *args, **kwargs)
  list_limit = hints.limit['limit']
  hints.set_limit((list_limit + 1))
  ref_list = f(self, hints, *args, **kwargs)
  if (len(ref_list) > list_limit):
   hints.set_limit(list_limit, truncated=True)
   return ref_list[:list_limit]
  else:
   hints.set_limit(list_limit)
   return ref_list
 return wrapper

def truncated ( f ) : @ functools . wraps ( f ) def wrapper ( self , hints , * args , ** kwargs ) : if ( not hasattr ( hints , 'limit' ) ) : raise exception . UnexpectedError ( _ ( 'Cannot truncate a driver call without hints list as first parameter after self ' ) ) if ( ( hints . limit is None ) or hints . filters ) : return f ( self , hints , * args , ** kwargs ) list_limit = hints . limit [ 'limit' ] hints . set_limit ( ( list_limit + 1 ) ) ref_list = f ( self , hints , * args , ** kwargs ) if ( len ( ref_list ) > list_limit ) : hints . set_limit ( list_limit , truncated = True ) return ref_list [ : list_limit ] else : hints . set_limit ( list_limit ) return ref_list return wrapper
ensure list truncation is detected in driver list entity methods .