[Python-checkins] r56180 - in sandbox/trunk/2to3: README examples examples/fix_ws_comma.py fixes/fix_ws_comma.py

collin.winter python-checkins at python.org
Fri Jul 6 15:42:13 CEST 2007


Author: collin.winter
Date: Fri Jul  6 15:42:13 2007
New Revision: 56180

Added:
   sandbox/trunk/2to3/examples/
   sandbox/trunk/2to3/examples/fix_ws_comma.py
      - copied unchanged from r56177, sandbox/trunk/2to3/fixes/fix_ws_comma.py
Removed:
   sandbox/trunk/2to3/fixes/fix_ws_comma.py
Modified:
   sandbox/trunk/2to3/README
Log:
Move fix_ws_comma out of fixes (we don't want it run by -f all).

Modified: sandbox/trunk/2to3/README
==============================================================================
--- sandbox/trunk/2to3/README	(original)
+++ sandbox/trunk/2to3/README	Fri Jul  6 15:42:13 2007
@@ -24,6 +24,7 @@
 pgen2/         - Parser generator and driver ([1]_, [2]_)
 fixes/         - Individual transformations
 tests/         - Test files for pytree, fixers, grammar, etc
+examples/      - Fixers that while neat, we don't want run by refactor's -f all
 
 
 Capabilities

Deleted: /sandbox/trunk/2to3/fixes/fix_ws_comma.py
==============================================================================
--- /sandbox/trunk/2to3/fixes/fix_ws_comma.py	Fri Jul  6 15:42:13 2007
+++ (empty file)
@@ -1,37 +0,0 @@
-"""Fixer that changes 'a ,b' into 'a, b'.
-
-This also changes '{a :b}' into '{a: b}', but does not touch other
-uses of colons.  It does not touch other uses of whitespace.
-
-"""
-
-import pytree
-from pgen2 import token
-from fixes import basefix
-
-class FixWsComma(basefix.BaseFix):
-
-  PATTERN = """
-  any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]>
-  """
-
-  COMMA = pytree.Leaf(token.COMMA, ",")
-  COLON = pytree.Leaf(token.COLON, ":")
-  SEPS = (COMMA, COLON)
-
-  def transform(self, node):
-    new = node.clone()
-    comma = False
-    for child in new.children:
-      if child in self.SEPS:
-        prefix = child.get_prefix()
-        if prefix.isspace() and "\n" not in prefix:
-          child.set_prefix("")
-        comma = True
-      else:
-        if comma:
-          prefix = child.get_prefix()
-          if not prefix:
-            child.set_prefix(" ")
-        comma = False
-    return new


More information about the Python-checkins mailing list