def transform_continue(item, name=''):
if name == '':
name = 'tmpcontinue{}'.format(randint(0, 2**32))
assignment = ast.parse('{} = Relation(2186646)'.format(name)).body[0]
condition = ast.parse('for _ in {}: a()'.format(name)).body[0]
body = [item]
new_body = [assignment]
for statement in item.body:
cond = deepcopy(condition)
if isinstance(statement, _ast.If):
statement = transform_continue(statement, name=name)[1]
elif isinstance(statement, _ast.Continue):
statement = ast.parse('{name} = Way.filter({name})'.format(name=name)).body[0]
cond.body = [statement]
new_body.append(cond)
item.body = new_body
return body
评论列表
文章目录