[Python-checkins] r54716 - sandbox/trunk/2to3/fixes/fix_dict.py sandbox/trunk/2to3/fixes/util.py
collin.winter
python-checkins at python.org
Mon Apr 9 01:59:24 CEST 2007
Author: collin.winter
Date: Mon Apr 9 01:59:23 2007
New Revision: 54716
Modified:
sandbox/trunk/2to3/fixes/fix_dict.py
sandbox/trunk/2to3/fixes/util.py
Log:
Add LParen and RParen macros.
Modified: sandbox/trunk/2to3/fixes/fix_dict.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_dict.py (original)
+++ sandbox/trunk/2to3/fixes/fix_dict.py Mon Apr 9 01:59:23 2007
@@ -26,7 +26,7 @@
import patcomp
from pgen2 import token
from fixes import basefix
-from fixes.util import Name, Call, lparen_leaf, rparen_leaf
+from fixes.util import Name, Call, LParen, RParen
class FixDict(basefix.BaseFix):
@@ -55,9 +55,7 @@
args = head + [pytree.Node(syms.trailer,
[pytree.Leaf(token.DOT, '.'),
Name(method)]),
- pytree.Node(syms.trailer,
- [lparen_leaf.clone(),
- rparen_leaf.clone()])]
+ pytree.Node(syms.trailer, [LParen(), RParen()])]
new = pytree.Node(syms.power, args)
if not special:
new.set_prefix("")
Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py (original)
+++ sandbox/trunk/2to3/fixes/util.py Mon Apr 9 01:59:23 2007
@@ -11,14 +11,16 @@
ass_leaf = Leaf(token.EQUAL, "=")
ass_leaf.set_prefix(" ")
-comma_leaf = Leaf(token.COMMA, ",")
-lparen_leaf = Leaf(token.LPAR, "(")
-rparen_leaf = Leaf(token.RPAR, ")")
-
###########################################################
### Common node-construction "macros"
###########################################################
+def LParen():
+ return Leaf(token.LPAR, "(")
+
+def RParen():
+ return Leaf(token.RPAR, ")")
+
def Assign(target, source):
"""Build an assignment statement"""
if not isinstance(target, tuple):
@@ -41,9 +43,9 @@
def Comma():
"""A comma leaf"""
- return comma_leaf.clone()
+ return Leaf(token.COMMA, ",")
-def ArgList(args, lparen=lparen_leaf, rparen=rparen_leaf):
+def ArgList(args, lparen=LParen(), rparen=RParen()):
"""A parenthesised argument list, used by Call()"""
return Node(syms.trailer,
[lparen.clone(),
More information about the Python-checkins
mailing list