def __init__(self, name):
        self.name = ''
        self.maxLength = None
        self.explode = False
        self.array = False
        
        if (name[0:1] not in URITemplate.varstart):
            raise BadVariable(name)
        
        if (':' in name):
            name, maxLength = name.split(':', 1)
            if ((0 < len(maxLength)) and (len(maxLength) < 4)):
                for digit in maxLength:
                    if (digit not in URITemplate.digit):
                        raise BadVariable(name + ':' + maxLength)
                self.maxLength = int(maxLength)
                if (not self.maxLength):
                    raise BadVariable(name + ':' + maxLength)
            else:
                raise BadVariable(name + ':' + maxLength)
        elif ('*' == name[-1]):
            name = name[:-1]
            self.explode = True
        elif ('[]' == name[-2:]):
            name = name[:-2]
            self.array = True
            self.explode = True
        
        index = 0
        while (index < len(name)):
            codepoint = name[index]
            if (('%' == codepoint) and
                ((index + 2) < len(name)) and
                (name[index + 1] in URITemplate.hexdigit) and
                (name[index + 2] in URITemplate.hexdigit)):
                self.name += name[index:index + 3]
                index += 2
            elif (codepoint in URITemplate.varchar):
                self.name += codepoint
            else:
                raise BadVariable(name + ((':' + self.maxLength) if (self.maxLength) else '') + ('[]' if (self.array) else ('*' if (self.explode) else '')))
            index += 1
dataset/ETHPy150Open tabatkins/bikeshed/bikeshed/apiclient/apiclient/uritemplate.py/Variable.__init__/original