hexrec.utils.columnize#
- hexrec.utils.columnize(line, width, sep='', newline='\\n', window=1)[source]#
Splits and wraps a line into columns.
A text line is wrapped up to a width limit, separated by a given newline string. Each wrapped line is then split into columns by some window size, separated by a given separator string.
- Parameters:
line (str) – Line of text to columnize.
width (int) – Maximum line width.
sep (str) – Column separator string.
newline (str) – Line separator string.
window (int) – Splitted column length.
- Returns:
str – A wrapped and columnized text.
Examples
>>> columnize('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 6) 'ABCDEF\nGHIJKL\nMNOPQR\nSTUVWX\nYZ'
>>> columnize('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 6, sep=' ', window=3) 'ABC DEF\nGHI JKL\nMNO PQR\nSTU VWX\nYZ'