Add a 'parent' attribute to Element that allows auto-addElement (the old syntax is still supported).
AFAIK 'parent' is not an attribute of any OpenDocument element, so we can use it to specify the Element in which to be created.
See the example passwd-as-ods.py:
f = open('/etc/passwd')
for line in f:
rec = line.strip().split(":")
tr = TableRow()
table.addElement(tr)
for val in rec:
tc = TableCell()
tr.addElement(tc)
p = P(stylename=tablecontents,text=unicode(val,PWENC))
tc.addElement(p)
becomes
with open('/etc/passwd') as f:
for line in f:
rec = line.strip().split(':')
tr = TableRow(parent=table)
for val in rec:
tc = TableCell(parent=tr)
p = P(parent=tc, stylename=tablecontents, text=val)
I haven't updated every example and documentation yet, because I wanted to get your opinion on this API change.
Add a 'parent' attribute to Element that allows auto-addElement (the old syntax is still supported).
AFAIK 'parent' is not an attribute of any OpenDocument element, so we can use it to specify the Element in which to be created.
See the example passwd-as-ods.py:
becomes
I haven't updated every example and documentation yet, because I wanted to get your opinion on this API change.