[Python-checkins] r56275 - sandbox/trunk/2to3/fixes/fix_dict.py sandbox/trunk/2to3/fixes/util.py

collin.winter python-checkins at python.org
Wed Jul 11 17:11:45 CEST 2007


Author: collin.winter
Date: Wed Jul 11 17:11:45 2007
New Revision: 56275

Modified:
   sandbox/trunk/2to3/fixes/fix_dict.py
   sandbox/trunk/2to3/fixes/util.py
Log:
Add a Dot() node macro.

Modified: sandbox/trunk/2to3/fixes/fix_dict.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_dict.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_dict.py	Wed Jul 11 17:11:45 2007
@@ -27,7 +27,7 @@
 import patcomp
 from pgen2 import token
 from fixes import basefix
-from fixes.util import Name, Call, LParen, RParen, ArgList
+from fixes.util import Name, Call, LParen, RParen, ArgList, Dot
 
 class FixDict(basefix.BaseFix):
     PATTERN = """
@@ -54,7 +54,7 @@
         tail = [n.clone() for n in tail]
         special = not tail and self.in_special_context(node, isiter)
         args = head + [pytree.Node(syms.trailer,
-                                   [pytree.Leaf(token.DOT, '.'),
+                                   [Dot(),
                                     Name(method_name,
                                          prefix=method.get_prefix())]),
                        results["parens"].clone()]

Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py	(original)
+++ sandbox/trunk/2to3/fixes/util.py	Wed Jul 11 17:11:45 2007
@@ -41,13 +41,16 @@
 
 def Attr(obj, attr):
     """A node tuple for obj.attr"""
-    return [obj,
-            Node(syms.trailer, [Leaf(token.DOT, '.'), attr])]
+    return [obj, Node(syms.trailer, [Dot(), attr])]
 
 def Comma():
     """A comma leaf"""
     return Leaf(token.COMMA, ",")
 
+def Dot():
+    """A period (.) leaf"""
+    return Leaf(token.DOT, ".")
+
 def ArgList(args, lparen=LParen(), rparen=RParen()):
     """A parenthesised argument list, used by Call()"""
     return Node(syms.trailer,


More information about the Python-checkins mailing list