[Checkins] SVN: zope.fixers/trunk/zope/fixers/ Checking in some fixes done earleir which I forgot the details of.
Lennart Regebro
regebro at gmail.com
Tue Apr 21 01:36:47 EDT 2009
Log message for revision 99345:
Checking in some fixes done earleir which I forgot the details of.
Changed:
U zope.fixers/trunk/zope/fixers/base.py
U zope.fixers/trunk/zope/fixers/tests.py
-=-
Modified: zope.fixers/trunk/zope/fixers/base.py
===================================================================
--- zope.fixers/trunk/zope/fixers/base.py 2009-04-20 22:55:35 UTC (rev 99344)
+++ zope.fixers/trunk/zope/fixers/base.py 2009-04-21 05:36:47 UTC (rev 99345)
@@ -155,10 +155,24 @@
for pattern in self.function_patterns:
if pattern.match(node, results):
parent = node.parent
+ previous = node.get_prev_sibling()
+ # Remove the node
node.remove()
if not str(parent).strip():
# This is an empty class. Stick in a pass
- parent.insert_child(2, Leaf(0, 'pass'))
+ if (len(parent.children) < 3 or
+ ' ' in parent.children[2].value):
+ # This class had no body whitespace.
+ parent.insert_child(2, Leaf(0, ' pass'))
+ else:
+ # This class had body whitespace already.
+ parent.insert_child(2, Leaf(0, 'pass'))
parent.insert_child(3, Leaf(0, '\n'))
+ elif (prefix and isinstance(previous, Leaf) and
+ '\n' not in previous.value and
+ previous.value.strip() == ''):
+ # This is just whitespace, remove it:
+ previous.remove()
+
return new_node
\ No newline at end of file
Modified: zope.fixers/trunk/zope/fixers/tests.py
===================================================================
--- zope.fixers/trunk/zope/fixers/tests.py 2009-04-20 22:55:35 UTC (rev 99344)
+++ zope.fixers/trunk/zope/fixers/tests.py 2009-04-21 05:36:47 UTC (rev 99345)
@@ -379,6 +379,12 @@
>>> class B(object):
... implements(I2)
+
+ >>> class Foo(object):
+ ... implements(IFoo)
+ ... x = 1
+ ... def __init__(self):
+ ... self.y = 2
"""
doctest_target = """
@@ -389,6 +395,12 @@
>>> @implementer(I2)
... class B(object):
... pass
+
+ >>> @implementer(IFoo)
+ ... class Foo(object):
+ ... x = 1
+ ... def __init__(self):
+ ... self.y = 2
"""
class DoctestFixerTest(FixerTest):
More information about the Checkins
mailing list