def make_exp(exp): check_type, out_name, concrete = None, None, None if len(exp) == 1 and exp[0][1] == '_': return (None, None, None) if len(exp) == 2 and exp[0][1] == '*' and exp[1][0] == NAME: exp = [(OP, '...'), (OP, ':'), exp[1]] if exp[0][1] in ('...', 'int', 'str', 'list', 'tuple'): check_type = exp[0][1] exp.pop(0) if len(exp) == 2 and exp[0][1] == ':': out_name = exp[1][1] elif len(exp) > 0: concrete = tokenize.untokenize(exp) #.decode() return (check_type, out_name, concrete)
def make_exp(exp): check_type, out_name, concrete = None, None, None if len(exp) == 1 and exp[0][1] == "_": return (None, None, None) if len(exp) == 2 and exp[0][1] == "*" and exp[1][0] == NAME: exp = [(OP, "..."), (OP, ":"), exp[1]] if exp[0][1] in ("...", "int", "str", "list", "tuple"): check_type = exp[0][1] exp.pop(0) if len(exp) == 2 and exp[0][1] == ":": out_name = exp[1][1] elif len(exp) > 0: concrete = tokenize.untokenize(exp) # .decode() return (check_type, out_name, concrete)
def __init__(self, *args, **kwargs): codecs.StreamReader.__init__(self, *args, **kwargs) data = tokenize.untokenize(translate(self.stream.readline)) self.stream = i.StringIO(data)
def untilde(x): return str( tokenize.untokenize(translate(BytesIO( x.encode('utf-8')).readline)).decode())