def indent(text: str, spaces: int):
    """
    Prepend every line of the specified text with a set number of spaces. Line endings are
    preserved.
    """
    prefix = " " * spaces
    return "".join(prefix + t for t in text.splitlines(keepends=True))