How to use the birdseye.utils.source_without_decorators function in birdseye

To help you get started, we’ve selected a few birdseye 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 / bird.py View on Github external
data_dict = dict(
            # This maps each node to the loops enclosing that node
            node_loops={
                node._tree_index: [n._tree_index for n in node._loops]
                for node, _ in nodes
                if node._loops
            },
        )
        if typ == 'function':
            tokens = traced_file.tokens
            func_node = only(node
                             for node, _ in nodes
                             if isinstance(node, ast.FunctionDef)
                             and node.first_token.start[0] == start_lineno)
            func_startpos, source = source_without_decorators(tokens, func_node)
            # These are for the PyCharm plugin
            data_dict.update(
                node_ranges=list(self._node_ranges(nodes, tokens, func_startpos)),
                loop_ranges=list(self._loop_ranges(nodes, tokens, func_startpos)),
            )

        data = json.dumps(data_dict, sort_keys=True)
        db_func = self._db_func(data, filename, html_body, name, start_lineno, source, typ)
        self._code_infos[code] = CodeInfo(db_func, traced_file, arg_names)
github alexmojaki / birdseye / birdseye / bird.py View on Github external
data_dict = dict(
            # This maps each node to the loops enclosing that node
            node_loops={
                node._tree_index: [n._tree_index for n in node._loops]
                for node, _ in nodes
                if node._loops
            },
        )
        if typ == 'function':
            tokens = traced_file.tokens
            func_node = only(node
                             for node, _ in nodes
                             if isinstance(node, ast.FunctionDef)
                             and node.first_token.start[0] == start_lineno)
            func_startpos, source = source_without_decorators(tokens, func_node)
            # These are for the PyCharm plugin
            data_dict.update(
                node_ranges=list(self._node_ranges(nodes, tokens, func_startpos)),
                loop_ranges=list(self._loop_ranges(nodes, tokens, func_startpos)),
            )

        data = json.dumps(data_dict, sort_keys=True)
        db_func = self._db_func(data, filename, html_body, name, start_lineno, source, typ)
        self._code_infos[code] = CodeInfo(db_func, traced_file, arg_names)