[Python-checkins] r73969 - in sandbox/trunk/2to3/lib2to3: refactor.py tests/test_refactor.py
benjamin.peterson
python-checkins at python.org
Sun Jul 12 03:50:43 CEST 2009
Author: benjamin.peterson
Date: Sun Jul 12 03:50:43 2009
New Revision: 73969
Log:
prefix headnode functions with '_'
Modified:
sandbox/trunk/2to3/lib2to3/refactor.py
sandbox/trunk/2to3/lib2to3/tests/test_refactor.py
Modified: sandbox/trunk/2to3/lib2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/refactor.py (original)
+++ sandbox/trunk/2to3/lib2to3/refactor.py Sun Jul 12 03:50:43 2009
@@ -41,7 +41,7 @@
pass
-def get_head_types(pat):
+def _get_head_types(pat):
""" Accepts a pytree Pattern Node and returns a set
of the pattern types which will match first. """
@@ -55,7 +55,7 @@
if isinstance(pat, pytree.NegatedPattern):
if pat.content:
- return get_head_types(pat.content)
+ return _get_head_types(pat.content)
raise _EveryNode # Negated Patterns don't have a type
if isinstance(pat, pytree.WildcardPattern):
@@ -63,13 +63,13 @@
r = set()
for p in pat.content:
for x in p:
- r.update(get_head_types(x))
+ r.update(_get_head_types(x))
return r
raise Exception("Oh no! I don't understand pattern %s" %(pat))
-def get_headnode_dict(fixer_list):
+def _get_headnode_dict(fixer_list):
""" Accepts a list of fixers and returns a dictionary
of head node type --> fixer list. """
head_nodes = collections.defaultdict(list)
@@ -77,7 +77,7 @@
for fixer in fixer_list:
if fixer.pattern:
try:
- heads = get_head_types(fixer.pattern)
+ heads = _get_head_types(fixer.pattern)
except _EveryNode:
every.append(fixer)
else:
@@ -153,8 +153,8 @@
logger=self.logger)
self.pre_order, self.post_order = self.get_fixers()
- self.pre_order_heads = get_headnode_dict(self.pre_order)
- self.post_order_heads = get_headnode_dict(self.post_order)
+ self.pre_order_heads = _get_headnode_dict(self.pre_order)
+ self.post_order_heads = _get_headnode_dict(self.post_order)
self.files = [] # List of files that were or should be modified
Modified: sandbox/trunk/2to3/lib2to3/tests/test_refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_refactor.py (original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_refactor.py Sun Jul 12 03:50:43 2009
@@ -76,7 +76,7 @@
no_head = NoneFix({}, [])
with_head = FileInputFix({}, [])
simple = SimpleFix({}, [])
- d = refactor.get_headnode_dict([no_head, with_head, simple])
+ d = refactor._get_headnode_dict([no_head, with_head, simple])
self.assertEqual(d[pygram.python_symbols.file_input],
[with_head, no_head, simple])
del d[pygram.python_symbols.file_input]
More information about the Python-checkins
mailing list