How to use the area4.util.reduce_to_unit function in area4

To help you get started, we’ve selected a few area4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github area4lib / area4 / area4 / __init__.py View on Github external
.. 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]