[Python-checkins] r54505 - sandbox/trunk/2to3/fixes/basefix.py sandbox/trunk/2to3/fixes/fix_ne.py sandbox/trunk/2to3/fixes/fix_numliterals.py

collin.winter python-checkins at python.org
Wed Mar 21 22:55:52 CET 2007


Author: collin.winter
Date: Wed Mar 21 22:55:52 2007
New Revision: 54505

Modified:
   sandbox/trunk/2to3/fixes/basefix.py
   sandbox/trunk/2to3/fixes/fix_ne.py
   sandbox/trunk/2to3/fixes/fix_numliterals.py
Log:
Remove the requirement for simple fixers (those that don't require PATTERN) to override compile_pattern().

Modified: sandbox/trunk/2to3/fixes/basefix.py
==============================================================================
--- sandbox/trunk/2to3/fixes/basefix.py	(original)
+++ sandbox/trunk/2to3/fixes/basefix.py	Wed Mar 21 22:55:52 2007
@@ -14,7 +14,7 @@
     from sets import Set as set
 
 # Local imports
-import patcomp
+from patcomp import PatternCompiler
 import pygram
 
 class BaseFix(object):
@@ -27,7 +27,7 @@
     FixHasKey.
     """
 
-    PATTERN = None  # Subclass *must* override with a string literal
+    PATTERN = None  # Most subclasses should override with a string literal
     pattern = None  # Compiled pattern, set by compile_pattern()
     options = None  # Options object passed to initializer
     filename = None # The filename (set by set_filename)
@@ -53,7 +53,8 @@
         Subclass may override if it doesn't want to use
         self.{pattern,PATTERN} in .match().
         """
-        self.pattern = patcomp.PatternCompiler().compile_pattern(self.PATTERN)
+        if self.PATTERN is not None:
+            self.pattern = PatternCompiler().compile_pattern(self.PATTERN)
 
     def set_filename(self, filename):
         """Set the filename, and a logger derived from it.

Modified: sandbox/trunk/2to3/fixes/fix_ne.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_ne.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_ne.py	Wed Mar 21 22:55:52 2007
@@ -14,10 +14,6 @@
 
 class FixNe(basefix.BaseFix):
 
-    def compile_pattern(self):
-        # Override
-        pass
-
     def match(self, node):
         # Override
         return node.type == token.NOTEQUAL and node.value == "<>"

Modified: sandbox/trunk/2to3/fixes/fix_numliterals.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_numliterals.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_numliterals.py	Wed Mar 21 22:55:52 2007
@@ -12,10 +12,6 @@
 
 class FixNumliterals(basefix.BaseFix):
 
-    def compile_pattern(self):
-        # Override
-        pass
-
     def match(self, node):
         # Override
         return (node.type == token.NUMBER and


More information about the Python-checkins mailing list