Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.. note::
The generated string will be terminated
at the specified length regardless
of if all the input strings have been fully replicated.
A unit > 1 length may
not be able to be replicated to extend to the full length.
In this situation, the
string will be shorter than the specified length.
Example: unit of 10 characters and a specified length of
25 will contain 2 units for
a total length of 20 characters.
"""
# Reduce the size if possible to extend closer to full length:
if not literal_unit:
unit = utils.reduce_to_unit(unit)
repeats = (length - len(start + end)) // len(unit)
return (start + unit * repeats + end)[0:length]