コード例 #1
0
 def _With(self, node):
     for item in pycompat.get_ast_with_items(node):
         if item.optional_vars:
             self._update_evaluated(item.optional_vars, item.context_expr,
                                    '.__enter__()')
     for child in node.body:
         ast.walk(child, self)
コード例 #2
0
ファイル: pyobjectsdef.py プロジェクト: mcepl/rope
 def _With(self, node):
     for item in pycompat.get_ast_with_items(node):
         if item.optional_vars:
             self._update_evaluated(item.optional_vars,
                                    item.context_expr, '.__enter__()')
     for child in node.body:
         ast.walk(child, self)
コード例 #3
0
 def _With(self, node):
     children = []
     for item in pycompat.get_ast_with_items(node):
         children.extend(['with', item.context_expr])
         if item.optional_vars:
             children.extend(['as', item.optional_vars])
     children.append(':')
     children.extend(node.body)
     self._handle(node, children)
コード例 #4
0
    def _handle_with_node(self, node, is_async):
        children = []

        if is_async:
            children.extend(["async"])
        for item in pycompat.get_ast_with_items(node):
            children.extend([self.with_or_comma_context_manager, item.context_expr])
            if item.optional_vars:
                children.extend(["as", item.optional_vars])
        if pycompat.PY2 and COMMA_IN_WITH_PATTERN.search(self.source.source):
            children.append(node.body[0])
        else:
            children.append(":")
            children.extend(node.body)
        self._handle(node, children)