File: fix_parrot.py

package info (click to toggle)
python3-stdlib-extensions 3.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 26,768 kB
  • sloc: python: 106,061; ansic: 19,492; sh: 198; makefile: 154
file content (13 lines) | stat: -rw-r--r-- 347 bytes parent folder | download | duplicates (50)
1
2
3
4
5
6
7
8
9
10
11
12
13
from lib2to3.fixer_base import BaseFix
from lib2to3.fixer_util import Name

class FixParrot(BaseFix):
    """
    Change functions named 'parrot' to 'cheese'.
    """

    PATTERN = """funcdef < 'def' name='parrot' any* >"""

    def transform(self, node, results):
        name = results["name"]
        name.replace(Name("cheese", name.prefix))