Ejemplo n.º 1
0
 def build_With(ctx, stmt):
     r = ctx.make_range(stmt.lineno, stmt.col_offset, stmt.col_offset + len("with"))
     # Handle ignore context manager
     if is_torch_jit_ignore_context_manager(stmt):
         if not _IS_ASTUNPARSE_INSTALLED:
             raise RuntimeError("torch.jit._IgnoreContextManager requires installing Python library `astunparse`,\
                                please install it in your Python environment")
         assign_ast = build_ignore_context_manager(ctx, stmt)
         return build_stmt(ctx, assign_ast)
     return With(r, build_withitems(ctx, stmt.items), build_stmts(ctx, stmt.body))
Ejemplo n.º 2
0
 def build_With(ctx, stmt):
     r = ctx.make_range(stmt.lineno, stmt.col_offset, stmt.col_offset + len("with"))
     return With(r, build_withitems(ctx, stmt.items), build_stmts(ctx, stmt.body))