PageRenderTime 56ms CodeModel.GetById 51ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/Lib/lib2to3/fixes/fix_buffer.py

http://unladen-swallow.googlecode.com/
Python | 21 lines | 11 code | 6 blank | 4 comment | 0 complexity | d6f8cc141ad7ab3f197f1638b9e3e1aa MD5 | raw file
 1# Copyright 2007 Google, Inc. All Rights Reserved.
 2# Licensed to PSF under a Contributor Agreement.
 3
 4"""Fixer that changes buffer(...) into memoryview(...)."""
 5
 6# Local imports
 7from .. import fixer_base
 8from ..fixer_util import Name
 9
10
11class FixBuffer(fixer_base.BaseFix):
12
13    explicit = True # The user must ask for this fixer
14
15    PATTERN = """
16              power< name='buffer' trailer< '(' [any] ')' > >
17              """
18
19    def transform(self, node, results):
20        name = results["name"]
21        name.replace(Name("memoryview", prefix=name.get_prefix()))