[Python-checkins] r54866 - in sandbox/trunk/2to3: HACKING fixes/fix_dummy.py

collin.winter python-checkins at python.org
Wed Apr 18 07:42:05 CEST 2007


Author: collin.winter
Date: Wed Apr 18 07:42:01 2007
New Revision: 54866

Added:
   sandbox/trunk/2to3/fixes/fix_dummy.py   (contents, props changed)
Modified:
   sandbox/trunk/2to3/HACKING
Log:
Add a dummy fixer and advice on how to use it.

Modified: sandbox/trunk/2to3/HACKING
==============================================================================
--- sandbox/trunk/2to3/HACKING	(original)
+++ sandbox/trunk/2to3/HACKING	Wed Apr 18 07:42:01 2007
@@ -6,6 +6,11 @@
     * If your fixer works by changing a node's children list or a leaf's
       value, be sure to call the node/leaf's changed() method. This to
       be sure refactor.py will recognize that the tree has changed.
+      
+    * If you're making changes to pgen2, tokenize or any other part of the
+      parsing system (sometimes even pytree), you might want to check out
+      the 'dummy' fixer. It doesn't make any changes to the file, so you
+      just see what the parser does.
 
 
 

Added: sandbox/trunk/2to3/fixes/fix_dummy.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/2to3/fixes/fix_dummy.py	Wed Apr 18 07:42:01 2007
@@ -0,0 +1,16 @@
+# Copyright 2007 Google, Inc. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""This is a pass-through fixer. It can be useful when changing certain
+parts of the parser or pytree."""
+
+# Local imports
+from fixes import basefix
+
+class FixDummy(basefix.BaseFix):
+
+    def match(self, node):
+        return True
+
+    def transform(self, node):
+        node.changed()


More information about the Python-checkins mailing list