Permalink
Browse files

Added range fix

  • Loading branch information...
1 parent 618dbcb commit 17af340f7bb2423f1f04d2c57880a50dece67fe1 @mitsuhiko mitsuhiko committed Feb 4, 2012
Showing with 33 additions and 7 deletions.
  1. +32 −0 libmodernize/fixes/fix_range.py
  2. +1 −7 libmodernize/fixes/fix_zip.py
@@ -0,0 +1,32 @@
+# Copyright 2008 Armin Ronacher.
+# Licensed to PSF under a Contributor Agreement.
+
+from lib2to3 import fixer_base
+from lib2to3.fixer_util import touch_import
+
+
+class FixRange(fixer_base.BaseFix):
+
+ BM_compatible = True
+ order = "pre"
+
+ PATTERN = """
+ power< 'range'
+ trailer< '('
+ arglist< (
+ (not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any) |
+ (not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any) |
+ (not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any ','
+ not(argument<any '=' any>) any)
+ ) >
+ ')' >
+ >
+ """
+
+ def transform(self, node, results):
+ touch_import(u'six.moves', u'range', node)
@@ -13,13 +13,7 @@ class FixZip(fixer_base.BaseFix):
PATTERN = """
power< 'map'
trailer< '('
- arglist< (
- (not(argument<any '=' any>) any ','
- not(argument<any '=' any>) any) |
- (not(argument<any '=' any>) any ','
- not(argument<any '=' any>) any ','
- not(argument<any '=' any>) any)
- ) >
+ arglist< any+ >
')' >
>
"""

0 comments on commit 17af340

Please sign in to comment.