How to use the snoop.utils.is_comprehension_frame function in snoop

To help you get started, we’ve selected a few snoop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexmojaki / executing / tests / samples / tracer2.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local
        thread_local.__dict__.setdefault('depth', -1)
        frame_info = self.frame_infos[frame]
        if event in ('call', 'enter'):
            thread_local.depth += 1
        elif self.config.last_frame and self.config.last_frame is not frame:
            line_no = frame_info.last_line_no
github alexmojaki / executing / tests / samples / tracer2.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local
github alexmojaki / executing / tests / samples / tracer2.py View on Github external
def __init__(self, frame):
        self.frame = frame
        self.local_reprs = {}
        self.last_line_no = frame.f_lineno
        self.comprehension_variables = OrderedDict()
        self.source = Source.for_frame(frame)
        self.is_generator = frame.f_code.co_flags & inspect.CO_GENERATOR
        self.had_exception = False
        if is_comprehension_frame(frame):
            self.comprehension_type = (
                    re.match(r'<(\w+)comp>', frame.f_code.co_name).group(1).title()
                    + u' comprehension'
            )
        else:
            self.comprehension_type = ''
github alexmojaki / snoop / snoop / tracer.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local
        thread_local.__dict__.setdefault('depth', -1)
        frame_info = self.frame_infos[frame]
        if event in ('call', 'enter'):
            thread_local.depth += 1
        elif self.config.last_frame and self.config.last_frame is not frame:
            line_no = frame_info.last_line_no
github alexmojaki / snoop / snoop / tracer.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local