def __init__(self, template):
        self.template = template

        self.parts = []
        parts = re.split(r'(\{[^\}]*\})', self.template)
        for part in parts:
            if (part):
                if (('{' == part[0]) and ('}' == part[-1])):
                    expression = part[1:-1]
                    if (re.match('^([a-zA-Z0-9_]|%[0-9a-fA-F][0-9a-fA-F]).*$', expression)):
                        self.parts.append(SimpleExpansion(expression))
                    elif ('+' == part[1]):
                        self.parts.append(ReservedExpansion(expression))
                    elif ('#' == part[1]):
                        self.parts.append(FragmentExpansion(expression))
                    elif ('.' == part[1]):
                        self.parts.append(LabelExpansion(expression))
                    elif ('/' == part[1]):
                        self.parts.append(PathExpansion(expression))
                    elif (';' == part[1]):
                        self.parts.append(PathStyleExpansion(expression))
                    elif ('?' == part[1]):
                        self.parts.append(FormStyleQueryExpansion(expression))
                    elif ('&' == part[1]):
                        self.parts.append(FormStyleQueryContinuation(expression))
                    elif (part[1] in '=,!@|'):
                        raise UnsupportedExpression(part)
                    else:
                        raise BadExpression(part)
                else:
                    if (('{' not in part) and ('}' not in part)):
                        self.parts.append(Literal(part))
                    else:
                        raise BadExpression(part)
dataset/ETHPy150Open tabatkins/bikeshed/bikeshed/apiclient/apiclient/uritemplate.py/URITemplate.__init__/original