cpl_query.base package
Submodules
cpl_query.base.default_lambda module
- cpl_query.base.default_lambda.default_lambda(x: object)
cpl_query.base.ordered_queryable module
- class cpl_query.base.ordered_queryable.OrderedQueryable(_t: type, _values: Iterable | None = None, _func: Callable | None = None)
Bases:
OrderedQueryableABC
Implementation of :class: cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
- then_by(_func: Callable) OrderedQueryableABC
Sorts OrderedList in ascending order by function
- Parameter:
func:
Callable
- Returns:
list of
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
- then_by_descending(_func: Callable) OrderedQueryableABC
Sorts OrderedList in descending order by function
- Parameter:
func:
Callable
- Returns:
list of
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
cpl_query.base.ordered_queryable_abc module
- class cpl_query.base.ordered_queryable_abc.OrderedQueryableABC(_t: type, _values: Iterable | None = None, _func: Callable | None = None)
Bases:
QueryableABC
- abstract then_by(func: Callable) OrderedQueryableABC
Sorts OrderedList in ascending order by function
- Parameter:
func:
Callable
- Returns:
list of
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
- abstract then_by_descending(func: Callable) OrderedQueryableABC
Sorts OrderedList in descending order by function
- Parameter:
func:
Callable
- Returns:
list of
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
cpl_query.base.queryable_abc module
- class cpl_query.base.queryable_abc.QueryableABC(t: type, values: Iterable | None = None)
Bases:
Sequence
- all(_func: Callable | None = None) bool
Checks if every element of list equals result found by function
Parameter
- func:
Callable
selected value
Returns
bool
- func:
- any(_func: Callable | None = None) bool
Checks if list contains result found by function
Parameter
- func:
Callable
selected value
Returns
bool
- func:
- average(_func: Callable | None = None) int | float | complex
Returns average value of list
Parameter
- func:
Callable
selected value
Returns
Union[int, float, complex]
- func:
- contains(_value: object) bool
Checks if list contains value given by function
Parameter
- value:
object
value
Returns
bool
- value:
- count(_func: Callable | None = None) int
Returns length of list or count of found elements
Parameter
- func:
Callable
selected value
Returns
int
- func:
- distinct(_func: Callable | None = None) QueryableABC
Returns list without redundancies
Parameter
- func:
Callable
selected value
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- func:
- element_at(_index: int) any
Returns element at given index
Parameter
- _index:
int
index
Returns
Value at _index: any
- _index:
- element_at_or_default(_index: int) any | None
Returns element at given index or None
Parameter
- _index:
int
index
Returns
Value at _index: Optional[any]
- _index:
- first_or_default() any
Returns first element or None
Returns
First element of list: Optional[any]
- for_each(_func: Callable | None = None)
Runs given function for each element of list
Parameter
- func: :class: Callable
function to call
- group_by(_func: Callable | None = None) QueryableABC
Groups by func
Returns
Grouped list[list[any]]: any
- max(_func: Callable | None = None) object
Returns the highest value
Parameter
- func:
Callable
selected value
Returns
object
- func:
- median(_func=None) int | float
Return the median value of data elements
Returns
Union[int, float]
- min(_func: Callable | None = None) object
Returns the lowest value
Parameter
- func:
Callable
selected value
Returns
object
- func:
- order_by(_func: Callable = None) OrderedQueryableABC
Sorts elements by function in ascending order
Parameter
- func:
Callable
selected value
Returns
- class:
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
- func:
- order_by_descending(_func: Callable = None) OrderedQueryableABC
Sorts elements by function in descending order
Parameter
- func:
Callable
selected value
Returns
- class:
cpl_query.base.ordered_queryable_abc.OrderedQueryableABC
- func:
- reverse() QueryableABC
Reverses list
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- select(_func: Callable) QueryableABC
Formats each element of list to a given format
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- select_many(_func: Callable) QueryableABC
Flattens resulting lists to one
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- single() any
Returns one single element of list
Returns
Found value: any
Raises
ArgumentNoneException: when argument is None Exception: when argument is None or found more than one element
- single_or_default() any | None
Returns one single element of list
Returns
Found value: Optional[any]
- skip(_index: int) QueryableABC
Skips all elements from index
Parameter
- _index:
int
index
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- _index:
- skip_last(_index: int) QueryableABC
Skips all elements after index
Parameter
- _index:
int
index
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- _index:
- split(_func: Callable) QueryableABC
Splits the list by given function
Parameter
- func:
Callable
seperator
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- func:
- sum(_func: Callable | None = None) int | float | complex
Sum of all values
Parameter
- func:
Callable
selected value
Returns
Union[int, float, complex]
- func:
- take(_index: int) QueryableABC
Takes all elements from index
Parameter
- _index:
int
index
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- _index:
- take_last(_index: int) QueryableABC
Takes all elements after index
Parameter
- _index:
int
index
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- _index:
- where(_func: Callable | None = None) QueryableABC
Select element by function
Parameter
- func:
Callable
selected value
Returns
- class:
cpl_query.base.queryable_abc.QueryableABC
- func:
cpl_query.base.sequence module
- class cpl_query.base.sequence.Sequence(t: type, values: Iterable | None = None)
Bases:
ABC
- classmethod empty() Sequence
Returns an empty sequence
- Returns:
Sequence object that contains no elements
- index_of(_object: object) int
Returns the index of given element
- Returns:
Index of object
- Raises:
IndexError if object not in sequence
- to_list() list
Converts :class: cpl_query.base.sequence_abc.SequenceABC to :class: list
- Returns:
- class:
list
- property type: type
Module contents
cpl-query CPL Queries
CPL Python integrated Queries
- copyright:
2021 - 2023 sh-edraft.de
- license:
MIT, see LICENSE for more details.