def StringFill(_string, _len, fill_front = False, fill_spaces = False):
    """Function to fill the string _string up to length _len
    with dots. If len(_string) > _len, the string is cropped.
    **kwargs: fill_front = True to fill in front of the input string.
    (Preset fill_front = False)
    Examples:
    StringFill('test 123', 12) = 'test 123 ...'
    StringFill('test 123', 12, fill_front = True) = '... test 123'
    """
    tmp = len(_string)
    if tmp < _len:
        if fill_spaces == False:
            if fill_front == True:
                return (_len-tmp-1)*'.'+' '+_string
            else:
                return _string+' '+(_len-tmp-1)*'.'
        else:
            if fill_front == True:
                return (_len-tmp)*' '+_string
            else:
                return _string+(_len-tmp)*' '

    else:
        return _string[:_len]