'Convert a string into a list of Limit instances.
This implementation expects a semicolon-separated sequence of
parenthesized groups, where each group contains a
comma-separated sequence consisting of HTTP method,
user-readable URI, a URI reg-exp, an integer number of
requests which can be made, and a unit of measure.  Valid
values for the latter are "SECOND", "MINUTE", "HOUR", and
"DAY".
@return: List of Limit instances.'

@staticmethod
def parse_limits(limits):

    limits = limits.strip()
    if (not limits):
        return []
    result = []
    for group in limits.split(';'):
        group = group.strip()
        if ((group[:1] != '(') or (group[(-1):] != ')')):
            raise ValueError('Limit    rules    must    be    surrounded    by    parentheses')
        group = group[1:(-1)]
        args = [a.strip() for a in group.split(',')]
        if (len(args) != 5):
            raise ValueError('Limit    rules    must    contain    the    following    arguments:    verb,    uri,    regex,    value,    unit')
        (verb, uri, regex, value, unit) = args
        verb = verb.upper()
        value = int(value)
        unit = unit.upper()
        if (unit not in Limit.UNIT_MAP):
            raise ValueError('Invalid    units    specified')
        unit = Limit.UNIT_MAP[unit]
        result.append(Limit(verb, uri, regex, value, unit))
    return result
