Renamed files

This commit is contained in:
2021-07-27 11:22:29 +02:00
parent 669133d491
commit 6951a19670
11 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
from typing import Optional
from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument
from cpl_query.extension.iterable_abc import IterableABC
def single_query(_list: IterableABC) -> any:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) > 1:
raise Exception('Found more than one element')
elif len(_list) == 0:
raise Exception('Found no element')
return _list[0]
def single_or_default_query(_list: IterableABC) -> Optional[any]:
if _list is None:
raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) > 1:
raise Exception('Index out of range')
elif len(_list) == 0:
return None
return _list[0]