Skip to content

Instantly share code, notes, and snippets.

@aisk
Created February 2, 2016 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aisk/05f9a9e39383785e8da0 to your computer and use it in GitHub Desktop.
Save aisk/05f9a9e39383785e8da0 to your computer and use it in GitHub Desktop.
import ast
def menu(*args, **kwargs):
def inner(f):
pass
return inner
a = ast.parse('''
@menu('xxx', parent='xxx')
class Xxx(object):
pass
''')
for node in ast.walk(a):
if type(node) == ast.ClassDef:
for decorator in node.decorator_list:
if d.func.id == 'menu':
# do some thing with d
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment