2012-08-05 12:32:57 +02:00
|
|
|
"""Fixer for itervalues -> values methods."""
|
|
|
|
# Author: Valentin Lorentz
|
|
|
|
|
|
|
|
# Code modified from fix_nonzero by Collin Winter
|
|
|
|
|
|
|
|
from lib2to3 import fixer_base
|
|
|
|
from lib2to3.fixer_util import Name, syms
|
|
|
|
|
|
|
|
class FixDefItervalues(fixer_base.BaseFix):
|
|
|
|
BM_compatible = True
|
|
|
|
PATTERN = """
|
|
|
|
classdef< 'class' any+ ':'
|
|
|
|
suite< any*
|
|
|
|
funcdef< 'def' name='itervalues'
|
|
|
|
parameters< '(' NAME ')' > any+ >
|
|
|
|
any* > >
|
|
|
|
"""
|
|
|
|
|
|
|
|
def transform(self, node, results):
|
|
|
|
name = results["name"]
|
2013-01-06 13:34:13 +01:00
|
|
|
new = Name("values", prefix=name.prefix)
|
2012-08-05 12:32:57 +02:00
|
|
|
name.replace(new)
|