Skip to content

climate_ref.text #

Helpers for the text the REF shows a person.

pluralise(count, singular, plural=None) #

Render a count and its noun, e.g. 1 diagnostic or 5 diagnostics.

Parameters:

Name Type Description Default
count int

How many there are.

required
singular str

The noun in its singular form.

required
plural str | None

The plural form, when appending an "s" does not give it.

None

Returns:

Type Description
str

The count followed by the noun in the matching form.

Source code in packages/climate-ref/src/climate_ref/text.py
def pluralise(count: int, singular: str, plural: str | None = None) -> str:
    """
    Render a count and its noun, e.g. ``1 diagnostic`` or ``5 diagnostics``.

    Parameters
    ----------
    count
        How many there are.
    singular
        The noun in its singular form.
    plural
        The plural form, when appending an "s" does not give it.

    Returns
    -------
    :
        The count followed by the noun in the matching form.
    """
    noun = singular if count == 1 else (plural or f"{singular}s")
    return f"{count} {noun}"