[Python-checkins] r54501 - sandbox/trunk/2to3/fixes/fix_print.py sandbox/trunk/2to3/fixes/util.py

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


Author: collin.winter
Date: Wed Mar 21 22:20:59 2007
New Revision: 54501
Modified:
 sandbox/trunk/2to3/fixes/fix_print.py
 sandbox/trunk/2to3/fixes/util.py
Log:
Add a String() leaf construction macro.
Modified: sandbox/trunk/2to3/fixes/fix_print.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_print.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_print.py	Wed Mar 21 22:20:59 2007
@@ -14,7 +14,7 @@
 import pytree
 from pgen2 import token
 from fixes import basefix
-from fixes.util import Name, Call, Comma
+from fixes.util import Name, Call, Comma, String
 
 
 class FixPrint(basefix.BaseFix):
@@ -56,11 +56,9 @@
 l_args[0].set_prefix("")
 if sep is not None or end is not None or file is not None:
 if sep is not None:
- self.add_kwarg(l_args, "sep",
- pytree.Leaf(token.STRING, repr(sep)))
+ self.add_kwarg(l_args, "sep", String(repr(sep)))
 if end is not None:
- self.add_kwarg(l_args, "end",
- pytree.Leaf(token.STRING, repr(end)))
+ self.add_kwarg(l_args, "end", String(repr(end)))
 if file is not None:
 self.add_kwarg(l_args, "file", file)
 n_stmt = Call(Name("print"), l_args)
Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py	(original)
+++ sandbox/trunk/2to3/fixes/util.py	Wed Mar 21 22:20:59 2007
@@ -62,6 +62,10 @@
 return Node(syms.trailer, [Leaf(token.LBRACE, '['),
 index_node,
 Leaf(token.RBRACE, ']')])
+ 
+def String(string, prefix=None):
+ """A string leaf"""
+ return Leaf(token.STRING, string, prefix=prefix)
 
 def is_tuple(node):
 """Does the node represent a tuple literal?"""


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /