Moved last queries

This commit is contained in:
2021-07-27 11:47:13 +02:00
parent e7863a92e0
commit c115afd736
3 changed files with 21 additions and 26 deletions

View File

@@ -1,24 +0,0 @@
from typing import Optional
from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument, IndexOutOfRangeException
from cpl_query.extension.iterable_abc import IterableABC
def first_query(_list: IterableABC) -> any:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) == 0:
raise IndexOutOfRangeException()
return _list[0]
def first_or_default_query(_list: IterableABC) -> Optional[any]:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) == 0:
return None
return _list[0]

View File

@@ -4,6 +4,26 @@ from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument, Index
from cpl_query.extension.iterable_abc import IterableABC
def first_query(_list: IterableABC) -> any:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) == 0:
raise IndexOutOfRangeException()
return _list[0]
def first_or_default_query(_list: IterableABC) -> Optional[any]:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) == 0:
return None
return _list[0]
def last_query(_list: IterableABC) -> any:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)