예제 #1
0
 def collectLoopVars(n):
     if isinstance(n, ast.Name):
         vars.append(n.id)
     elif isinstance(n, ast.expr_context):
         return
     else:
         for c in ast.iter_child_nodes(n):
             collectLoopVars(c)
예제 #2
0
 def collectLoopVars(n):
     if isinstance(n, ast.Name):
         vars.append(n.id)
     elif isinstance(n, ast.expr_context):
         return
     else:
         for c in ast.iter_child_nodes(n):
             collectLoopVars(c)
예제 #3
0
 def TRY(self, node):
     handler_names = []
     # List the exception handlers
     for handler in node.handlers:
         if isinstance(handler.type, ast.Tuple):
             for exc_type in handler.type.elts:
                 handler_names.append(node_name(exc_type))
         elif handler.type:
             handler_names.append(node_name(handler.type))
     # Memorize the except handlers and process the body
     self.except_handlers.append(handler_names)
     for child in node.body:
         self.handleNode(child, node)
     self.except_handlers.pop()
     # Process the other nodes: "except:", "else:", "finally:"
     for child in ast.iter_child_nodes(node):
         if child not in node.body:
             self.handleNode(child, node)
예제 #4
0
 def TRY(self, node):
     handler_names = []
     # List the exception handlers
     for handler in node.handlers:
         if isinstance(handler.type, ast.Tuple):
             for exc_type in handler.type.elts:
                 handler_names.append(node_name(exc_type))
         elif handler.type:
             handler_names.append(node_name(handler.type))
     # Memorize the except handlers and process the body
     self.except_handlers.append(handler_names)
     for child in node.body:
         self.handleNode(child, node)
     self.except_handlers.pop()
     # Process the other nodes: "except:", "else:", "finally:"
     for child in ast.iter_child_nodes(node):
         if child not in node.body:
             self.handleNode(child, node)
예제 #5
0
 def handle_children(self, tree):
     for node in ast.iter_child_nodes(tree):
         self.handleNode(node, tree)
예제 #6
0
 def handle_children(self, tree):
     for node in ast.iter_child_nodes(tree):
         self.handleNode(node, tree)