cloup._util

Generic utilities.

Functions Summary

cloup._util.class_name(obj)

cloup._util.check_arg(condition[, msg])

cloup._util.indent_lines(lines[, width])

cloup._util.make_repr(obj, *args[, …])

Generate repr(obj).

cloup._util.make_one_line_repr(obj, *args, …)

cloup._util.pluralize(count[, zero, one, many])

Contents

cloup._util.class_name(obj)[source]
cloup._util.check_arg(condition: bool, msg: str = '')[source]
Parameters
  • condition (bool) –

  • msg (str) –

cloup._util.indent_lines(lines: Iterable[str], width=2) → List[str][source]
Parameters

lines (Iterable[str]) –

Return type

List[str]

cloup._util.make_repr(obj, *args, _line_len: int = 60, _indent: int = 2, **kwargs)str[source]

Generate repr(obj).

Parameters
  • obj – object to represent

  • args – 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 – keyword arguments in the repr

Returns

str

Return type

str

cloup._util.make_one_line_repr(obj, *args, **kwargs)[source]
cloup._util.pluralize(count: int, zero: str = '', one: str = '', many: str = '')str[source]
Parameters
  • count (int) –

  • zero (str) –

  • one (str) –

  • many (str) –

Return type

str