How to use the snoop.utils.FormattedValue 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 / snoop / snoop / pp_module.py View on Github external
_treetrace_hidden_after_expr(_treetrace_hidden_before_expr(_tree_index), e)

        where the _treetrace_* functions are the corresponding methods with the
        TreeTracerBase and traced_file arguments already filled in (see _trace_methods_dict)
        """

        before_marker = ast.Call(
            func=ast.Name(id=self.before_name,
                          ctx=ast.Load()),
            args=[ast.Num(node._tree_index)],
            keywords=[],
        )

        ast.copy_location(before_marker, node)
        
        if isinstance(node, FormattedValue):
            arg = node
        else:
            arg = super(NodeVisitor, self).generic_visit(node)

        after_marker = ast.Call(
            func=ast.Name(id=self.after_name,
                          ctx=ast.Load()),
            args=[
                before_marker,
                arg,
            ],
            keywords=[],
        )
        ast.copy_location(after_marker, node)
        ast.fix_missing_locations(after_marker)
github alexmojaki / snoop / snoop / formatting.py View on Github external
def get_text_with_indentation(self, node):
        result = self.asttokens().get_text(node)
        
        if not result:
            if isinstance(node, FormattedValue):
                fvals = [
                    n for n in node.parent.values
                    if isinstance(n, FormattedValue)
                ]
                return u''.format(
                    optional_numeric_label(
                        fvals.index(node),
                        fvals,
                    )
                )
            else:
                return ""
        
        if '\n' in result:
            result = ' ' * node.first_token.start[1] + result
            result = dedent(result)
github alexmojaki / snoop / snoop / formatting.py View on Github external
def get_text_with_indentation(self, node):
        result = self.asttokens().get_text(node)
        
        if not result:
            if isinstance(node, FormattedValue):
                fvals = [
                    n for n in node.parent.values
                    if isinstance(n, FormattedValue)
                ]
                return ''.format(
                    optional_numeric_label(
                        fvals.index(node),
                        fvals,
                    )
                )
            else:
                return ""
        
        if '\n' in result:
            result = ' ' * node.first_token.start[1] + result
            result = dedent(result)
        else:
            result = result.strip()
        return result
github alexmojaki / snoop / snoop / formatting.py View on Github external
def get_text_with_indentation(self, node):
        result = self.asttokens().get_text(node)
        
        if not result:
            if isinstance(node, FormattedValue):
                fvals = [
                    n for n in node.parent.values
                    if isinstance(n, FormattedValue)
                ]
                return u''.format(
                    optional_numeric_label(
                        fvals.index(node),
                        fvals,
                    )
                )
            else:
                return ""
        
        if '\n' in result:
            result = ' ' * node.first_token.start[1] + result
            result = dedent(result)
        else:
            result = result.strip()
        return result
github alexmojaki / snoop / snoop / formatting.py View on Github external
def get_text_with_indentation(self, node):
        result = self.asttokens().get_text(node)
        
        if not result:
            if isinstance(node, FormattedValue):
                fvals = [
                    n for n in node.parent.values
                    if isinstance(n, FormattedValue)
                ]
                return ''.format(
                    optional_numeric_label(
                        fvals.index(node),
                        fvals,
                    )
                )
            else:
                return ""
        
        if '\n' in result:
            result = ' ' * node.first_token.start[1] + result
            result = dedent(result)