Last change
on this file was 391, checked in by dmik, 11 years ago |
python: Merge vendor 2.7.6 to trunk.
|
-
Property svn:eol-style
set to
native
|
File size:
839 bytes
|
Line | |
---|
1 | # Copyright 2008 Armin Ronacher.
|
---|
2 | # Licensed to PSF under a Contributor Agreement.
|
---|
3 |
|
---|
4 | """Fixer for reduce().
|
---|
5 |
|
---|
6 | Makes sure reduce() is imported from the functools module if reduce is
|
---|
7 | used in that module.
|
---|
8 | """
|
---|
9 |
|
---|
10 | from lib2to3 import fixer_base
|
---|
11 | from lib2to3.fixer_util import touch_import
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 | class FixReduce(fixer_base.BaseFix):
|
---|
16 |
|
---|
17 | BM_compatible = True
|
---|
18 | order = "pre"
|
---|
19 |
|
---|
20 | PATTERN = """
|
---|
21 | power< 'reduce'
|
---|
22 | trailer< '('
|
---|
23 | arglist< (
|
---|
24 | (not(argument<any '=' any>) any ','
|
---|
25 | not(argument<any '=' any>) any) |
|
---|
26 | (not(argument<any '=' any>) any ','
|
---|
27 | not(argument<any '=' any>) any ','
|
---|
28 | not(argument<any '=' any>) any)
|
---|
29 | ) >
|
---|
30 | ')' >
|
---|
31 | >
|
---|
32 | """
|
---|
33 |
|
---|
34 | def transform(self, node, results):
|
---|
35 | touch_import(u'functools', u'reduce', node)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.