m = ast.parse("""
dic = {"name": "aa", "version": 10}
setup(name=dic["name"], version=dic["version"])
""")
import peval
from peval.components import fold
r, v = fold(m, {})
print(astor.to_source(r, indent_with='\t',), v)
My use case is automatic safe parsing of metadata from setup.py files. The plan is simple: process the AST with a constant and copy propagation optimizer, then extract the data from setup call.
Also: I had to comment out some asserts in expression.py.
My use case is automatic safe parsing of metadata from
setup.pyfiles. The plan is simple: process the AST with a constant and copy propagation optimizer, then extract the data fromsetupcall.Also: I had to comment out some asserts in
expression.py.