[Python-checkins] r66647 - sandbox/trunk/2to3/lib2to3/refactor.py

benjamin.peterson python-checkins at python.org
Sat Sep 27 19:28:28 CEST 2008


Author: benjamin.peterson
Date: Sat Sep 27 19:28:28 2008
New Revision: 66647

Log:
let fixer modules and classes have different prefixes

Modified:
   sandbox/trunk/2to3/lib2to3/refactor.py

Modified: sandbox/trunk/2to3/lib2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/refactor.py	(original)
+++ sandbox/trunk/2to3/lib2to3/refactor.py	Sat Sep 27 19:28:28 2008
@@ -98,6 +98,9 @@
 
     _default_options = {"print_function": False}
 
+    CLASS_PREFIX = "Fix" # The prefix for fixer classes
+    FILE_PREFIX = "fix_" # The prefix for modules with a fixer within
+
     def __init__(self, fixer_names, options=None, explicit=None):
         """Initializer.
 
@@ -140,10 +143,10 @@
         for fix_mod_path in self.fixers:
             mod = __import__(fix_mod_path, {}, {}, ["*"])
             fix_name = fix_mod_path.rsplit(".", 1)[-1]
-            if fix_name.startswith("fix_"):
-                fix_name = fix_name[4:]
+            if fix_name.startswith(self.FILE_PREFIX):
+                fix_name = fix_name[len(self.FILE_PREFIX):]
             parts = fix_name.split("_")
-            class_name = "Fix" + "".join([p.title() for p in parts])
+            class_name = self.CLASS_PREFIX + "".join([p.title() for p in parts])
             try:
                 fix_class = getattr(mod, class_name)
             except AttributeError:


More information about the Python-checkins mailing list