stdlib_ext

Some of the Python Standard Library methods rewritten for correct work with strings containing control sequences.

pytermor.util.stdlib_ext.center_aware(s: str, width: int, fillchar: str = ' ') str

SGR-formatting-aware implementation of str.center.

Return a centered string of length width. Padding is done using the specified fill character (default is a space).

pytermor.util.stdlib_ext.ljust_sgr(s: str, width: int, fillchar: str = ' ') str

SGR-formatting-aware implementation of str.ljust.

Return a left-justified string of length width. Padding is done using the specified fill character (default is a space).

pytermor.util.stdlib_ext.rjust_aware(s: str, width: int, fillchar: str = ' ') str

SGR-formatting-aware implementation of str.rjust.

Return a right-justified string of length width. Padding is done using the specified fill character (default is a space).