Exemplo n.º 1
0
 def prepr(self, depth=0, dchr=' '):
     dstr = dchr * depth
     return '%s%sscope :\n%s %s%s' % (
         dstr, self.name + '-' if self.name else '', dstr,
         ('\n%s ' % dstr).join(
             ['%s => %r' % (x, y) for x, y in self.dict.items()]),
         '\n' + '\n'.join([prepr(p, depth + 1)
                           for p in self.parents] if self.parents else []))
Exemplo n.º 2
0
	def prepr(self, depth=0, dchr=' '):
		dstr=dchr*depth
		return '%s%sscope :\n%s %s%s'%(
			dstr, self.name + '-' if self.name else '',
			dstr, ('\n%s '%dstr).join(['%s => %r'%(x,y) for x,y in self.dict.items()]),
			'\n'+
			'\n'.join([prepr(p, depth+1) for p in self.parents] if self.parents else [])
		)
Exemplo n.º 3
0
 def visit(self, tree_node, local_dict):
     last_context = self.last_node, self.last_scope
     self.last_node, self.last_scope = tree_node, local_dict
     if VERBOSE >= VERBOSITY_SHOW_VISITED_NODES:
         print "Visiting %s (line %s) : %s %s" % (
             tree_node.filename, tree_node.line_num, tree_node.name,
             prepr.prepr(local_dict))
     fn = getattr(self, 'exec_%s' % tree_node.name, None)
     if fn is not None:
         retval = fn(tree_node, local_dict)
     else:
         retval = self.visit_default(tree_node, local_dict)
     self.last_node, self.last_scope = last_context
     return retval
Exemplo n.º 4
0
	def tfn(*a,**b):
		global trace_stack, tcid
		cur_tcid = tcid
		tcid += 1
		trace_stack.append(tcid)
		trace_depth = len(trace_stack)
		tpid = trace_stack[-2] if trace_depth >= 2 else None
		fn_name = fn.__name__
		pdata = {
			'indent' : "|"*trace_depth,
			'name'   : fn_name,
			'args'   : prepr.prepr(a),
			'kwargs' : b,
			'depth'  : trace_depth,
			'parent_tcid': tpid,
			'tcid'   : cur_tcid
		}
		print pre_tt % pdata
		rv = fn(*a,**b)
		print post_tt % pdata
		trace_stack.pop()
		return rv
Exemplo n.º 5
0
 def tfn(*a, **b):
     global trace_stack, tcid
     cur_tcid = tcid
     tcid += 1
     trace_stack.append(tcid)
     trace_depth = len(trace_stack)
     tpid = trace_stack[-2] if trace_depth >= 2 else None
     fn_name = fn.__name__
     pdata = {
         'indent': "|" * trace_depth,
         'name': fn_name,
         'args': prepr.prepr(a),
         'kwargs': b,
         'depth': trace_depth,
         'parent_tcid': tpid,
         'tcid': cur_tcid
     }
     print pre_tt % pdata
     rv = fn(*a, **b)
     print post_tt % pdata
     trace_stack.pop()
     return rv
Exemplo n.º 6
0
	def visit(self, tree_node, local_dict):
		last_context = self.last_node, self.last_scope
		self.last_node, self.last_scope  = tree_node, local_dict
		if VERBOSE >= VERBOSITY_SHOW_VISITED_NODES:
			print "Visiting %s (line %s) : %s %s"%(tree_node.filename, tree_node.line_num, tree_node.name, prepr.prepr(local_dict))
		fn = getattr(self, 'exec_%s'%tree_node.name, None)
		if fn is not None:
			retval = fn(tree_node, local_dict)
		else:
			retval = self.visit_default(tree_node, local_dict)
		self.last_node, self.last_scope = last_context
		return retval