'Takes the pattern and splits it into components.
Each grouping pattern is expanded into a set:
/foo{a,b}/bar -> ["/foo", set(["a", "b"]), "/bar"]
Raises:
ValueError: Unknown pattern or interpolation.
NotImplementedError: The pattern is using knowledgebase interpolations,
they are not implemented client side yet.
Args:
pattern: list of patterns.
Returns:
A list of interpolated patterns.'

def _InterpolateGrouping(self, pattern):

    result = []
    components = []
    offset = 0
    for match in self.GROUPING_PATTERN.finditer(pattern):
        match_str = match.group(0)
        if match_str.startswith('{'):
            components.append([pattern[offset:match.start()]])
            alternatives = match.group(2).split(',')
            components.append(set(alternatives))
            offset = match.end()
        elif match_str.startswith('%'):
            raise NotImplementedError('Client    side    knowledgebase    not    available.')
        else:
            raise ValueError(('Unknown    interpolation    %s' % match.group(0)))
    components.append([pattern[offset:]])
    for vector in itertools.product(*components):
        result.append(u''.join(vector))
    return result
