def _do_TupleExpression(self, node, context): if context == OP_APPLY: nodes = map(self.transform, node.Items) return ast.Tuple(nodes) else: transform = lambda node: self.transform(node, context) nodes = map(transform, node.Items) return ast.AssTuple(nodes)
def p_testlist(p): """testlist : testlist_multi COMMA | testlist_multi """ if len(p) == 2: p[0] = p[1] else: # May need to promote singleton to tuple if isinstance(p[1], list): p[0] = p[1] else: p[0] = [p[1]] # Convert into a tuple? if isinstance(p[0], list): p[0] = ast.Tuple(p[0])
def comma(self, *elems): "," for e in elems: assertResult(e, "use in tuple") return ast.Tuple(map(topy, elems))
def tuple(obj): for x in obj: assertResult(x, 'use in tuple') return ast.Tuple(map(topy, obj))
def paren(self, expr): "(" if expr == None: return ast.Tuple() return topy(expr)
def compileTuple(doc): for x in doc: assertResult(x, "use in tuple") return ast.Tuple([topy(x) for x in doc])
def BUILD_TUPLE(decompiler, size): return ast.Tuple(decompiler.pop_items(size))
def visitSubscript(self, node): return ast.CallFunc(ast.Name('_lookup_item'), [ ast.Name('data'), self.visit(node.expr), ast.Tuple([self.visit(sub) for sub in node.subs]) ])