Ejemplo n.º 1
0
 def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression:
     # Each of n.values is a str or FormattedValue; we just concatenate
     # them all using ''.join.
     empty_string = StrExpr('')
     empty_string.set_line(n.lineno, n.col_offset)
     strs_to_join = ListExpr(self.translate_expr_list(n.values))
     strs_to_join.set_line(empty_string)
     join_method = MemberExpr(empty_string, 'join')
     join_method.set_line(empty_string)
     result_expression = CallExpr(join_method, [strs_to_join],
                                  [ARG_POS], [None])
     return result_expression
Ejemplo n.º 2
0
 def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression:
     # Each of n.values is a str or FormattedValue; we just concatenate
     # them all using ''.join.
     empty_string = StrExpr('')
     empty_string.set_line(n.lineno, n.col_offset)
     strs_to_join = ListExpr(self.translate_expr_list(n.values))
     strs_to_join.set_line(empty_string)
     join_method = MemberExpr(empty_string, 'join')
     join_method.set_line(empty_string)
     result_expression = CallExpr(join_method,
                                  [strs_to_join],
                                  [ARG_POS],
                                  [None])
     return result_expression
Ejemplo n.º 3
0
 def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]:
     expr_list: List[Expression] = [self.visit(e) for e in n.elts]
     if isinstance(n.ctx, ast27.Store):
         # [x, y] = z and (x, y) = z means exactly the same thing
         e: Union[ListExpr, TupleExpr] = TupleExpr(expr_list)
     else:
         e = ListExpr(expr_list)
     return self.set_line(e, n)
Ejemplo n.º 4
0
 def visit_List(self, n: ast35.List) -> Node:
     return ListExpr([self.visit(e) for e in n.elts])
Ejemplo n.º 5
0
 def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]:
     expr_list = [self.visit(e) for e in n.elts]  # type: List[Expression]
     if isinstance(n.ctx, ast27.Store):
         # [x, y] = z and (x, y) = z means exactly the same thing
         return TupleExpr(expr_list)
     return ListExpr(expr_list)
Ejemplo n.º 6
0
 def visit_list_expr(self, node: ListExpr) -> Node:
     return ListExpr(self.nodes(node.items))
Ejemplo n.º 7
0
 def visit_List(self, n: ast27.List) -> ListExpr:
     return ListExpr([self.visit(e) for e in n.elts])
Ejemplo n.º 8
0
 def visit_list_expr(self, node: ListExpr) -> ListExpr:
     return ListExpr(self.expressions(node.items))
Ejemplo n.º 9
0
 def visit_List(self, n):
     return ListExpr([self.visit(e) for e in n.elts])