what-studio / astdispatch

Visits AST nodes by singledispatch-like API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

astdispatch

singledispatch-like API to visit all Python AST nodes.

[![Build Status] (https://travis-ci.org/what-studio/astdispatch.svg)] (https://travis-ci.org/what-studio/astdispatch) [![Coverage Status] (https://img.shields.io/coveralls/what-studio/astdispatch.svg)] (https://coveralls.io/r/what-studio/astdispatch)

@astdispatch(transform=True)
def rewrite_name(node):
    return node

@rewrite_name.register(ast.Name)
def _(node):
    return ast.copy_location(ast.Subscript(
        value=ast.Name(id='data', ctx=ast.Load()),
        slice=ast.Index(value=ast.Str(s=node.id)),
        ctx=node.ctx), node)

Written by Heungsub Lee at What! Studio in Nexon, and distributed under the BSD 3-Clause license.

About

Visits AST nodes by singledispatch-like API

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%