mirror of
https://github.com/iluvcapra/pycmx.git
synced 2026-01-01 01:10:55 +00:00
18 lines
372 B
Python
18 lines
372 B
Python
# pycmx
|
|
# (c) 2018 Jamie Hardt
|
|
|
|
# Utility functions
|
|
|
|
def collimate(a_string, column_widths):
|
|
'Splits a string into substrings that are column_widths length.'
|
|
|
|
if len(column_widths) == 0:
|
|
return []
|
|
|
|
width = column_widths[0]
|
|
element = a_string[:width]
|
|
rest = a_string[width:]
|
|
return [element] + collimate(rest, column_widths[1:])
|
|
|
|
|