UtilitiesPython2/py2flakes/checker.py

changeset 2088
73a2ca4ac409
parent 1544
d06ffad32855
child 2302
f29e9405c851
equal deleted inserted replaced
2087:795992a5c561 2088:73a2ca4ac409
283 return isinstance(node, _ast.Str) or \ 283 return isinstance(node, _ast.Str) or \
284 (isinstance(node, _ast.Expr) and 284 (isinstance(node, _ast.Expr) and
285 isinstance(node.value, _ast.Str)) 285 isinstance(node.value, _ast.Str))
286 286
287 def handleNode(self, node, parent): 287 def handleNode(self, node, parent):
288 node.parent = parent 288 if node:
289 if self.traceTree: 289 node.parent = parent
290 print ' ' * self.nodeDepth + node.__class__.__name__ 290 if self.traceTree:
291 self.nodeDepth += 1 291 print ' ' * self.nodeDepth + node.__class__.__name__
292 if self.futuresAllowed and not \ 292 self.nodeDepth += 1
293 (isinstance(node, _ast.ImportFrom) or self.isDocstring(node)): 293 if self.futuresAllowed and not \
294 self.futuresAllowed = False 294 (isinstance(node, _ast.ImportFrom) or self.isDocstring(node)):
295 nodeType = node.__class__.__name__.upper() 295 self.futuresAllowed = False
296 try: 296 nodeType = node.__class__.__name__.upper()
297 handler = getattr(self, nodeType) 297 try:
298 handler(node) 298 handler = getattr(self, nodeType)
299 finally: 299 handler(node)
300 self.nodeDepth -= 1 300 except AttributeError:
301 if self.traceTree: 301 print nodeType, "not supported yet. Please report this."
302 print ' ' * self.nodeDepth + 'end ' + node.__class__.__name__ 302 finally:
303 self.nodeDepth -= 1
304 if self.traceTree:
305 print ' ' * self.nodeDepth + 'end ' + node.__class__.__name__
303 306
304 def ignore(self, node): 307 def ignore(self, node):
305 pass 308 pass
306 309
307 # "stmt" type nodes 310 # "stmt" type nodes

eric ide

mercurial