cloup._util
¶
Generic utilities.
Classes¶
|
|
A class used just as frozen namespace for constants. |
Functions¶
|
|
|
|
|
|
|
Generate repr(obj). |
|
|
|
|
|
Returns the first value that is not None (or None if no such value exists). |
|
Returns the first bool (or raises StopIteration if no bool is found). |
|
|
|
|
|
|
|
|
|
Attributes¶
Contents¶
- cloup._util.click_version_tuple¶
- cloup._util.click_major¶
- cloup._util.click_minor¶
- cloup._util.click_version_ge_8_1¶
- cloup._util.T¶
- cloup._util.K¶
- cloup._util.V¶
- cloup._util.pick_non_missing(d)[source]¶
- Parameters
d (Dict[cloup._util.K, Union[cloup.typing._Missing, cloup._util.V]]) –
- Return type
Dict[cloup._util.K, cloup._util.V]
- cloup._util.check_arg(condition, msg='')[source]¶
- Parameters
condition (bool) –
msg (str) –
- Return type
None
- cloup._util.indent_lines(lines, width=2)[source]¶
- Parameters
lines (Iterable[str]) –
width (int) –
- Return type
List[str]
- cloup._util.make_repr(obj, *args, _line_len=60, _indent=2, **kwargs)[source]¶
Generate repr(obj).
- Parameters
obj (Any) – object to represent
args (Any) – positional arguments in the repr
_line_len (int) – if the repr length exceeds this, arguments will be on their own line; if negative, the repr will be in a single line regardless of its length
_indent (int) – indentation width of arguments in case they are shown in their own line
kwargs (Any) – keyword arguments in the repr
- Returns
str
- Return type
str
- cloup._util.make_one_line_repr(obj, *args, **kwargs)[source]¶
- Parameters
obj (object) –
args (Any) –
kwargs (Any) –
- Return type
str
- cloup._util.pluralize(count, zero='', one='', many='')[source]¶
- Parameters
count (int) –
zero (str) –
one (str) –
many (str) –
- Return type
str
- cloup._util.coalesce(*values)[source]¶
Returns the first value that is not None (or None if no such value exists).
- Parameters
values (Optional[cloup._util.T]) –
- Return type
Optional[cloup._util.T]
- cloup._util.first_bool(*values)[source]¶
Returns the first bool (or raises StopIteration if no bool is found).
- Parameters
values (Any) –
- Return type
bool
- cloup._util.pick_not_none(iterable)[source]¶
- Parameters
iterable (Iterable[Optional[cloup._util.T]]) –
- Return type
List[cloup._util.T]
- cloup._util.check_positive_int(value, arg_name)[source]¶
- Parameters
value (Any) –
arg_name (str) –
- Return type
None
- class cloup._util.FrozenSpaceMeta(*args)[source]¶
Bases:
type
- Parameters
args (Any) –
- class cloup._util.FrozenSpace[source]¶
A class used just as frozen namespace for constants.
- Return type
None