def remove_literals(source): module = ast.parse(source, 'remove_literals') add_namespace(module) bind_names(module) resolve_names(module) return RemovePass()(module)
def remove_literals(source): module = ast.parse(source, 'test_remove_literal_statements') add_namespace(module) bind_names(module) resolve_names(module) return RemoveLiteralStatements()(module)
def do_rename(source): # This will raise if the source file can't be parsed module = ast.parse(source, 'test_rename_bultins') add_namespace(module) bind_names(module) resolve_names(module) allow_rename_locals(module, True) allow_rename_globals(module, True) rename(module) return module
def rename(source, locals, globals): # This will raise if the source file can't be parsed module = ast.parse(source, 'test_match_rename') add_namespace(module) bind_names(module) resolve_names(module) allow_rename_locals(module, locals) allow_rename_globals(module, globals) rename_literals(module) do_rename(module) return module