# 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

  any(_func: Callable | None = None) → bool

    Checks if list contains result found by function

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > bool

  average(_func: Callable | None = None) → int | float | complex

    Returns average value of list

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > Union[int, float, complex]

  contains(_value: object) → bool

    Checks if list contains value given by function

    ### Parameter

    > value: `object`

    >   value

    ### Returns

    > bool

  count(_func: Callable | None = None) → int

    Returns length of list or count of found elements

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > int

  distinct(_func: Callable | None = None) → QueryableABC

    Returns list without redundancies

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

  element_at(_index: int) → any

    Returns element at given index

    ### Parameter

    > _index: `int`

    >   index

    ### Returns

    > Value at _index: any

  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]

  first() → any

    Returns first element

    ### Returns

    > First element of list: any

  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

  last() → any

    Returns last element

    ### Returns

    > Last element of list: any

  last_or_default() → any

    Returns last element or None

    ### Returns

    > Last element of list: Optional[any]

  max(_func: Callable | None = None) → object

    Returns the highest value

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > object

  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

  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

  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

  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

  skip_last(_index: int) → QueryableABC

    Skips all elements after index

    ### Parameter

    > _index: `int`

    >   index

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

  split(_func: Callable) → QueryableABC

    Splits the list by given function

    ### Parameter

    > func: `Callable`

    >   seperator

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

  sum(_func: Callable | None = None) → int | float | complex

    Sum of all values

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > Union[int, float, complex]

  take(_index: int) → QueryableABC

    Takes all elements from index

    ### Parameter

    > _index: `int`

    >   index

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

  take_last(_index: int) → QueryableABC

    Takes all elements after index

    ### Parameter

    > _index: `int`

    >   index

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

  where(_func: Callable | None = None) → QueryableABC

    Select element by function

    ### Parameter

    > func: `Callable`

    >   selected value

    ### Returns

    > class:

    >   cpl_query.base.queryable_abc.QueryableABC

## cpl_query.base.sequence module

class cpl_query.base.sequence.Sequence(t: type, values: Iterable | None = None)

  Bases: `ABC`

  copy() → Sequence

    Creates a copy of sequence

    Returns:

      Sequence

  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

  classmethod range(start: int, length: int) → 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:

  3. 2021 - 2023 sh-edraft.de

license:

  MIT, see LICENSE for more details.

class cpl_query.base.VersionInfo(major, minor, micro)

  Bases: `tuple`

  major

    Alias for field number 0

  micro

    Alias for field number 2

  minor

    Alias for field number 1