summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2009-11-19 15:39:40 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2009-11-19 15:39:40 -0500
commitee3130deb4312fd541a89eb6f885375ec6935cd3 (patch)
treef6ca7635d1d5822839368792147b0e27e386a87e
parent4fa4447a66af6d6dc165e4a90b90d9fcce6e4689 (diff)
download2to3c-ee3130deb4312fd541a89eb6f885375ec6935cd3.tar.gz
2to3c-ee3130deb4312fd541a89eb6f885375ec6935cd3.tar.xz
2to3c-ee3130deb4312fd541a89eb6f885375ec6935cd3.zip
Get typeobject fixups working for dbus-python/_dbus_bindings/abstract.c
-rw-r--r--typeobject.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/typeobject.py b/typeobject.py
index 17dfafd..8e4da1f 100644
--- a/typeobject.py
+++ b/typeobject.py
@@ -7,18 +7,18 @@ req_ws = r'\s+'
opt_ws = r'\s*'
c_identifier = r'([_A-Za-z][_0-9A-Za-z]*)'
-pat = (r'PyTypeObject' + req_ws
+pat = ('.*' + r'PyTypeObject' + req_ws
+ c_identifier + opt_ws
+ r'=' + opt_ws + r'\{' + opt_ws
+ r'(PyObject_HEAD_INIT\((.*)\)' + opt_ws
- + r'([0-9]+)' + opt_ws + r',)'
+ + r'([0-9]+)' + opt_ws + r',).*'
)
def fixup_typeobject_initializers(content):
while True:
- m = re.match(pat, content)
+ m = re.match(pat, content, re.DOTALL)
if m:
- if True:
+ if False:
print m.groups()
print m.group(2)
print m.group(3)
@@ -33,13 +33,15 @@ def fixup_typeobject_initializers(content):
import unittest
class TestFixups(unittest.TestCase):
def test_fixups(self):
- self.assertEquals(fixup_typeobject_initializers('''PyTypeObject DBusPyIntBase_Type = {
+ self.assertEquals(fixup_typeobject_initializers('''
+PyTypeObject DBusPyIntBase_Type = {
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
0,
"_dbus_bindings._IntBase",
'''
),
- '''PyTypeObject DBusPyIntBase_Type = {
+ '''
+PyTypeObject DBusPyIntBase_Type = {
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
"_dbus_bindings._IntBase",
'''