cloup._util

Generic utilities.

Functions Summary

class_name(obj)

check_arg(condition[, msg])

indent_lines(lines[, width])

make_repr(obj, *args[, _line_len, _indent])

Generate repr(obj).

make_one_line_repr(obj, *args, **kwargs)

pluralize(count[, zero, one, many])

Contents

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

  • msg (str) –

cloup._util.indent_lines(lines, width=2)[source]
Parameters

lines (Iterable[str]) –

Return type

List[str]

cloup._util.make_repr(obj, *args, _line_len=60, _indent=2, **kwargs)[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, zero='', one='', many='')[source]
Parameters
  • count (int) –

  • zero (str) –

  • one (str) –

  • many (str) –

Return type

str