How to use the snoop.utils.optional_numeric_label 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
def write_placeholder(self, i, arg):
        source = ''.format(optional_numeric_label(i, self.args))
        return self.write(source, arg)
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