Expand description
This module contains various helper functions for easier formatting and creation of user-friendly messages.
Enums§
Functions§
- a_or_an
- Returns indefinite article “a” or “an” that corresponds to the
word
, or an empty string if the indefinite article do not fit to the word. - ascii_
sentence_ case - Returns
text
with the first character turned into ASCII uppercase. - call_
path_ suffix_ with_ args - Returns the suffix of the
call_path
together with any type arguments if they exist. Convenient for subsequent showing of only the short name of a full name that was already shown. - did_
you_ mean - Finds strings from an iterable of
possible_values
similar to a given valuev
. Returns a vector of all possible values that exceed a similarity threshold, sorted by similarity (most similar comes first). The returned vector will have at mostmax_num_of_suggestions
elements. - first_
line - Returns the first line in
text
, up to the first\n
if thetext
contains multiple lines, and optionally adds ellipses “…” to the end of the line ifwith_ellipses
is true. - get_
file_ name - Returns the file name (with extension) for the provided
source_id
, orNone
if thesource_id
isNone
or the file name cannot be obtained. - is_are
- Returns “is” if
count
is 1, otherwise “are”. - number_
to_ str - Returns reading-friendly textual representation for
number
smaller than or equal to 10 or its numeric representation if it is greater than 10. - plural_
s - Returns “s” if
count
is different than 1, otherwise empty string. Convenient for building simple plural of words. - sequence_
to_ list - Returns reading-friendly textual representation of the
sequence
, with vertically listed items and each item indented for theindent
and preceded with the dash (-). If the sequence has more thanmax_items
the remaining items are replaced with the text “andmore”. - sequence_
to_ str - Returns reading-friendly textual representation of the
sequence
, with comma-separated items and each item optionally enclosed in the specifiedenclosing
. If the sequence has more thanmax_items
the remaining items are replaced with the text “andmore”. - sequence_
to_ str_ or - Returns reading-friendly textual representation of the
sequence
, with comma-separated items and each item optionally enclosed in the specifiedenclosing
. If the sequence has more thanmax_items
the remaining items are replaced with the text “ormore”. - singular_
plural - Returns
singular
ifcount
is 1, otherwiseplural
.