def replace_decorators(node, capture, filename): """ Replaces usage of ``@tornado.<etc>`` with ``@salt.ext.tornado.<etc>`` """ indent = find_indentation(node) decorator = _get_decorator(node) decorator.remove() decorated = Node( SYMBOL.decorated, [ Node( SYMBOL.decorator, [ Leaf(TOKEN.AT, "@"), Name("salt.ext.{}".format(get_decorator_name(decorator))), Leaf(TOKEN.NEWLINE, "\n"), ], ) ], prefix=decorator.prefix, ) node.replace(decorated) decorated.append_child(node) if indent is not None: node.prefix = indent else: node.prefix = ""
def add_marker(node, capture, filename): """Add ``MARKER`` to the functions.""" indent = _get_indent(node) decorated = Node( SYMBOL.decorated, [ Node( SYMBOL.decorator, [Leaf(TOKEN.AT, "@"), Name(MARKER), Leaf(TOKEN.NEWLINE, "\n")], ) ], prefix=node.prefix, ) node.replace(decorated) decorated.append_child(node) if indent is not None: node.prefix = indent else: node.prefix = ""