~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Lib/lib2to3/fixes/fix_intern.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2006 Georg Brandl.
 
2
# Licensed to PSF under a Contributor Agreement.
 
3
 
 
4
"""Fixer for intern().
 
5
 
 
6
intern(s) -> sys.intern(s)"""
 
7
 
 
8
# Local imports
 
9
from .. import fixer_base
 
10
from ..fixer_util import ImportAndCall, touch_import
 
11
 
 
12
 
 
13
class FixIntern(fixer_base.BaseFix):
 
14
    BM_compatible = True
 
15
    order = "pre"
 
16
 
 
17
    PATTERN = """
 
18
    power< 'intern'
 
19
           trailer< lpar='('
 
20
                    ( not(arglist | argument<any '=' any>) obj=any
 
21
                      | obj=arglist<(not argument<any '=' any>) any ','> )
 
22
                    rpar=')' >
 
23
           after=any*
 
24
    >
 
25
    """
 
26
 
 
27
    def transform(self, node, results):
 
28
        names = ('sys', 'intern')
 
29
        new = ImportAndCall(node, results, names)
 
30
        touch_import(None, 'sys', node)
 
31
        return new