Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def frame_for_stack(stack):
if len(stack) == 0:
return self._root_frame
parent = frame_for_stack(stack[:-1])
frame_name = stack[-1]
if not frame_name in parent.children:
parent.children[frame_name] = StatFrame(frame_name, parent)
return parent.children[frame_name]
def __init__(self, *args, **kwargs):
super(StatFrame, self).__init__(*args, **kwargs)
self.self_time = 0
def root_frame(self):
"""
Returns the parsed results in the form of a tree of Frame objects
"""
if not hasattr(self, '_root_frame'):
self._root_frame = StatFrame()
# define a recursive function that builds the heirarchy of frames given the
# stack of frame identifiers
def frame_for_stack(stack):
if len(stack) == 0:
return self._root_frame
parent = frame_for_stack(stack[:-1])
frame_name = stack[-1]
if not frame_name in parent.children:
parent.children[frame_name] = StatFrame(frame_name, parent)
return parent.children[frame_name]
for stack, self_time in self.stack_self_time.iteritems():