
:mod:`cloup.constraints.common`
===============================

.. py:module:: cloup.constraints.common

.. autoapi-nested-parse::

   Useful functions used to implement constraints and predicates.





                              

Functions
---------

.. autosummary::

   ~cloup.constraints.common.param_value_is_set
   ~cloup.constraints.common.get_param_name
   ~cloup.constraints.common.get_params_whose_value_is_set
   ~cloup.constraints.common.get_required_params
   ~cloup.constraints.common.get_param_label
   ~cloup.constraints.common.join_param_labels
   ~cloup.constraints.common.join_with_and
   ~cloup.constraints.common.format_param
   ~cloup.constraints.common.format_param_list
   ~cloup.constraints.common.param_label_by_name
   ~cloup.constraints.common.get_param_labels
   ~cloup.constraints.common.param_value_by_name


                                           
Contents
--------
.. py:function:: param_value_is_set(param, value)

   Define what it means for a parameter of a specific kind to be "set".

   All cases are obvious besides that of boolean options:
   - (common rule) if the value is ``None``, the parameter is unset;
   - a parameter that takes multiple values is set if at least one argument is provided;
   - a boolean **flag** is set only if True;
   - a boolean option is set if not None, even if it's False.


.. py:function:: get_param_name(param)

   Return the name of a parameter casted to ``str``.
   Use this function to avoid typing errors in places where you expect a parameter
   having a name.


.. py:function:: get_params_whose_value_is_set(params, values)

   Filter ``params``, returning only the parameters that have a value.
   Boolean flags are considered "set" if their value is ``True``.


.. py:function:: get_required_params(params)

.. py:function:: get_param_label(param)

.. py:function:: join_param_labels(params, sep = ', ')

.. py:function:: join_with_and(strings, sep = ', ')

.. py:function:: format_param(param)

.. py:function:: format_param_list(param_list, indent = 2)

.. py:function:: param_label_by_name(ctx, name)

.. py:function:: get_param_labels(ctx, param_names)

.. py:function:: param_value_by_name(ctx, name)


                                         