text_formatter.justify
- Justify the strings, according to a certain length#
Source code: text_formatter/justify.py
This module provides functions to modify the length of some text Python types, like str
or bytes
.
- text_formatter.justify.justify(s, length)#
- Parameters:
s (str) – The string to be justified.
length (int) – The expected length per line.
- Returns:
The string adjusted to the given length per line.
- Return type:
str
- Raises:
text_formatter.exceptions.InvalidString – if
text_formatter.check.checkString
failed.
A simple function to justify strings.
Warning
Even when this documentation is telling that
justify()
returns the adjusted string, at this moment it only returns an unmodifieds
. This function needs a larger development, so the actual documentation is not stable at all.Actually the whole project needs a more-stable development [1].
- text_formatter.justify.justify_bytes(b, length)#
- Parameters:
b (bytes) – The bytestring to be justified.
length – The expected length per line.
- Returns:
The bytestring adjusted to length
length
.- Return type:
bytes
- Raises:
text_formatter.exceptions.InvalidBytes – if
text_formatter.check.checkBytes
failed.
Probably the same than
justify()
, but converting byte-like strings instead of Python strings.Warning
Just like
justify()
, this function hasn’t been completed (yet), like most of thetext_formatter
features [1].
Footnotes