def parse_length(int_or_string):
    """
    Parses length value or keywords into value.

    Args:
        int_or_string: string with number or keyword.
    Returns:
        A integer.
    """
    try:
        return int(int_or_string)
    except:
        pass
    try:
        dictionary = {'day': 1, 'week': 7, 'month': 30, 'year': 365, 'inf':
            365 * 1000000, 'infinite': 365 * 1000000, 'max': 365 * 1000000}
        return dictionary[int_or_string.lower()]
    except:
        pass
    raise Exception('Invalid period: ' + int_or_string)
