@@ -47,17 +47,17 @@ def newdocument():
47
47
document .append (makeelement ('body' ))
48
48
return document
49
49
50
- def makeelement (tagname ,tagtext = None ,nsprefix = 'w' ,tagattributes = None ,attributenamespace = None ):
50
+ def makeelement (tagname ,tagtext = None ,nsprefix = 'w' ,attributes = None ,attributenamespace = None ):
51
51
'''Create an element & return it'''
52
52
namespace = '{' + nsprefixes [nsprefix ]+ '}'
53
53
newelement = etree .Element (namespace + tagname )
54
54
# Add attributes with namespaces
55
- if tagattributes :
55
+ if attributes :
56
56
# If they haven't bothered setting attribute namespace, use the same one as the tag
57
57
if not attributenamespace :
58
58
attributenamespace = namespace
59
- for tagattribute in tagattributes :
60
- newelement .set (attributenamespace + tagattribute , tagattributes [tagattribute ])
59
+ for tagattribute in attributes :
60
+ newelement .set (attributenamespace + tagattribute , attributes [tagattribute ])
61
61
if tagtext :
62
62
newelement .text = tagtext
63
63
return newelement
@@ -73,7 +73,7 @@ def pagebreak(type='page', orient='portrait'):
73
73
pagebreak = makeelement ('p' )
74
74
if type == 'page' :
75
75
run = makeelement ('r' )
76
- br = makeelement ('br' ,tagattributes = {'type' :type })
76
+ br = makeelement ('br' ,attributes = {'type' :type })
77
77
78
78
run .append (br )
79
79
pagebreak .append (run )
@@ -82,9 +82,9 @@ def pagebreak(type='page', orient='portrait'):
82
82
pPr = makeelement ('pPr' )
83
83
sectPr = makeelement ('sectPr' )
84
84
if orient == 'portrait' :
85
- pgSz = makeelement ('pgSz' ,tagattributes = {'w' :'12240' ,'h' :'15840' })
85
+ pgSz = makeelement ('pgSz' ,attributes = {'w' :'12240' ,'h' :'15840' })
86
86
elif orient == 'landscape' :
87
- pgSz = makeelement ('pgSz' ,tagattributes = {'h' :'12240' ,'w' :'15840' , 'orient' :'landscape' })
87
+ pgSz = makeelement ('pgSz' ,attributes = {'h' :'12240' ,'w' :'15840' , 'orient' :'landscape' })
88
88
89
89
sectPr .append (pgSz )
90
90
pPr .append (sectPr )
@@ -107,7 +107,7 @@ def paragraph(paratext,style='BodyText',breakbefore=False):
107
107
108
108
text = makeelement ('t' ,tagtext = paratext )
109
109
pPr = makeelement ('pPr' )
110
- pStyle = makeelement ('pStyle' ,tagattributes = {'val' :style })
110
+ pStyle = makeelement ('pStyle' ,attributes = {'val' :style })
111
111
pPr .append (pStyle )
112
112
113
113
@@ -124,7 +124,7 @@ def heading(headingtext,headinglevel):
124
124
# Make our elements
125
125
paragraph = makeelement ('p' )
126
126
pr = makeelement ('pPr' )
127
- pStyle = makeelement ('pStyle' ,tagattributes = {'val' :'Heading' + str (headinglevel )})
127
+ pStyle = makeelement ('pStyle' ,attributes = {'val' :'Heading' + str (headinglevel )})
128
128
run = makeelement ('r' )
129
129
text = makeelement ('t' ,tagtext = headingtext )
130
130
# Add the text the run, and the run to the paragraph
@@ -142,29 +142,29 @@ def table(contents):
142
142
columns = len (contents [0 ][0 ])
143
143
# Table properties
144
144
tableprops = makeelement ('tblPr' )
145
- tablestyle = makeelement ('tblStyle' ,tagattributes = {'val' :'ColorfulGrid-Accent1' })
146
- tablewidth = makeelement ('tblW' ,tagattributes = {'w' :'0' ,'type' :'auto' })
147
- tablelook = makeelement ('tblLook' ,tagattributes = {'val' :'0400' })
145
+ tablestyle = makeelement ('tblStyle' ,attributes = {'val' :'ColorfulGrid-Accent1' })
146
+ tablewidth = makeelement ('tblW' ,attributes = {'w' :'0' ,'type' :'auto' })
147
+ tablelook = makeelement ('tblLook' ,attributes = {'val' :'0400' })
148
148
for tableproperty in [tablestyle ,tablewidth ,tablelook ]:
149
149
tableprops .append (tableproperty )
150
150
table .append (tableprops )
151
151
# Table Grid
152
152
tablegrid = makeelement ('tblGrid' )
153
153
for _ in range (columns ):
154
- tablegrid .append (makeelement ('gridCol' ,tagattributes = {'gridCol' :'2390' }))
154
+ tablegrid .append (makeelement ('gridCol' ,attributes = {'gridCol' :'2390' }))
155
155
table .append (tablegrid )
156
156
# Heading Row
157
157
row = makeelement ('tr' )
158
158
rowprops = makeelement ('trPr' )
159
- cnfStyle = makeelement ('cnfStyle' ,tagattributes = {'val' :'000000100000' })
159
+ cnfStyle = makeelement ('cnfStyle' ,attributes = {'val' :'000000100000' })
160
160
rowprops .append (cnfStyle )
161
161
row .append (rowprops )
162
162
for heading in contents [0 ]:
163
163
cell = makeelement ('tc' )
164
164
# Cell properties
165
165
cellprops = makeelement ('tcPr' )
166
- cellwidth = makeelement ('tcW' ,tagattributes = {'w' :'2390' ,'type' :'dxa' })
167
- cellstyle = makeelement ('shd' ,tagattributes = {'val' :'clear' ,'color' :'auto' ,'fill' :'548DD4' ,'themeFill' :'text2' ,'themeFillTint' :'99' })
166
+ cellwidth = makeelement ('tcW' ,attributes = {'w' :'2390' ,'type' :'dxa' })
167
+ cellstyle = makeelement ('shd' ,attributes = {'val' :'clear' ,'color' :'auto' ,'fill' :'548DD4' ,'themeFill' :'text2' ,'themeFillTint' :'99' })
168
168
cellprops .append (cellwidth )
169
169
cellprops .append (cellstyle )
170
170
cell .append (cellprops )
@@ -179,7 +179,7 @@ def table(contents):
179
179
cell = makeelement ('tc' )
180
180
# Properties
181
181
cellprops = makeelement ('tcPr' )
182
- cellwidth = makeelement ('tcW' ,tagattributes = {'type' :'dxa' })
182
+ cellwidth = makeelement ('tcW' ,attributes = {'type' :'dxa' })
183
183
cellprops .append (cellwidth )
184
184
cell .append (cellprops )
185
185
# Paragraph (Content)
@@ -193,29 +193,29 @@ def picture():
193
193
# Word uses paragraphs to contain images
194
194
# http://openxmldeveloper.org/articles/462.aspx
195
195
#resourceid = rId5
196
- #newrelationship = makeelement('Relationship',tagattributes ={'Id':resourceid,'Type':'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'},Target=filename)
196
+ #newrelationship = makeelement('Relationship',attributes ={'Id':resourceid,'Type':'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'},Target=filename)
197
197
198
198
# Now make drawing element
199
199
#newpara = makeelement('deleteme',style='BodyText')
200
200
201
201
202
202
blipfill = makeelement ('blipFill' ,nsprefix = 'a' )
203
- blipfill .append (makeelement ('blip' ,nsprefix = 'a' ,tagattributes = {'embed' :'rId5' }))
203
+ blipfill .append (makeelement ('blip' ,nsprefix = 'a' ,attributes = {'embed' :'rId5' }))
204
204
stretch = makeelement ('stretch' ,nsprefix = 'a' )
205
205
stretch .append (makeelement ('fillRect' ,nsprefix = 'a' ))
206
206
blipfill .append (stretch )
207
207
208
208
sppr = makeelement ('spPr' ,nsprefix = 'pic' )
209
209
xfrm = makeelement ('xfrm' ,nsprefix = 'a' )
210
- xfrm .append (makeelement ('off' ,nsprefix = 'a' ,tagattributes = {'x' :'0' ,'y' :'0' }))
211
- xfrm .append (makeelement ('ext' ,nsprefix = 'a' ,tagattributes = {'cx' :'5486400' ,'cy' :'3429000' }))
212
- prstgeom = makeelement ('prstGeom' ,nsprefix = 'a' ,tagattributes = {'prst' :'rect' })
210
+ xfrm .append (makeelement ('off' ,nsprefix = 'a' ,attributes = {'x' :'0' ,'y' :'0' }))
211
+ xfrm .append (makeelement ('ext' ,nsprefix = 'a' ,attributes = {'cx' :'5486400' ,'cy' :'3429000' }))
212
+ prstgeom = makeelement ('prstGeom' ,nsprefix = 'a' ,attributes = {'prst' :'rect' })
213
213
prstgeom .append (makeelement ('avLst' ,nsprefix = 'a' ))
214
214
sppr .append (xfrm )
215
215
sppr .append (prstgeom )
216
216
217
217
nvpicpr = makeelement ('nvPicPr' ,nsprefix = 'a' )
218
- cnvpr = makeelement ('cNvPr' ,nsprefix = 'a' ,tagattributes = {'id' :'0' ,'name' :'aero_glow_v2_1920x1200.png' })
218
+ cnvpr = makeelement ('cNvPr' ,nsprefix = 'a' ,attributes = {'id' :'0' ,'name' :'aero_glow_v2_1920x1200.png' })
219
219
cnvpicpr = makeelement ('cNvPicPr' )
220
220
nvpicpr .append (cnvpicpr )
221
221
nvpicpr .append (cnvpr )
@@ -226,21 +226,21 @@ def picture():
226
226
pic .append (nvpicpr )
227
227
228
228
229
- graphicdata = makeelement ('graphicData' ,nsprefix = 'a' ,tagattributes = {'uri' :'http://schemas.openxmlformats.org/drawingml/2006/picture' })
229
+ graphicdata = makeelement ('graphicData' ,nsprefix = 'a' ,attributes = {'uri' :'http://schemas.openxmlformats.org/drawingml/2006/picture' })
230
230
graphicdata .append (pic )
231
231
232
232
graphic = makeelement ('graphic' ,nsprefix = 'a' )
233
233
graphic .append (graphicdata )
234
234
235
235
framepr = makeelement ('cNvGraphicFramePr' ,nsprefix = 'a' )
236
- framelocks = makeelement ('graphicFrameLocks' ,nsprefix = 'a' ,tagattributes = {'noChangeAspect' :'1' })
236
+ framelocks = makeelement ('graphicFrameLocks' ,nsprefix = 'a' ,attributes = {'noChangeAspect' :'1' })
237
237
framepr .append (framelocks )
238
238
239
239
makeelement ('drawing' )
240
- inline = makeelement ('inline' ,tagattributes = {'distT' :"0" ,'distB' :"0" ,'distL' :"0" ,'distR' :"0" },nsprefix = 'wp' )
241
- extent = makeelement ('extent' ,nsprefix = 'a' ,tagattributes = {'cx' :'5486400' ,'cy' :'3429000' })
242
- effectextent = makeelement ('effectExtent' ,nsprefix = 'a' ,tagattributes = {'l' :'25400' ,'t' :'0' ,'r' :'0' ,'b' :'0' })
243
- docpr = makeelement ('docPr' ,nsprefix = 'a' ,tagattributes = {'id' :'1' ,'name' :'Picture 0' ,'descr' :'aero_glow_v2_1920x1200.png' })
240
+ inline = makeelement ('inline' ,attributes = {'distT' :"0" ,'distB' :"0" ,'distL' :"0" ,'distR' :"0" },nsprefix = 'wp' )
241
+ extent = makeelement ('extent' ,nsprefix = 'a' ,attributes = {'cx' :'5486400' ,'cy' :'3429000' })
242
+ effectextent = makeelement ('effectExtent' ,nsprefix = 'a' ,attributes = {'l' :'25400' ,'t' :'0' ,'r' :'0' ,'b' :'0' })
243
+ docpr = makeelement ('docPr' ,nsprefix = 'a' ,attributes = {'id' :'1' ,'name' :'Picture 0' ,'descr' :'aero_glow_v2_1920x1200.png' })
244
244
inline .append (extent )
245
245
inline .append (effectextent )
246
246
inline .append (docpr )
@@ -347,9 +347,9 @@ def docproperties(title,subject,creator,keywords,lastmodifiedby=None):
347
347
<dcterms:modified xsi:type="dcterms:W3CDTF">2010-01-01T21:20:00Z</dcterms:modified>
348
348
currenttime'''
349
349
#docprops.append(makeelement('created',nsprefix='dcterms',
350
- #tagattributes ={'type':'dcterms:W3CDTF'},tagtext='2010-01-01T21:07:00Z',attributenamespace='xsi'))
350
+ #attributes ={'type':'dcterms:W3CDTF'},tagtext='2010-01-01T21:07:00Z',attributenamespace='xsi'))
351
351
#docprops.append(makeelement('modified',nsprefix='dcterms',
352
- #tagattributes ={'type':'dcterms:W3CDTF'},tagtext='2010-01-01T21:07:00Z',attributenamespace='xsi'))
352
+ #attributes ={'type':'dcterms:W3CDTF'},tagtext='2010-01-01T21:07:00Z',attributenamespace='xsi'))
353
353
return docprops
354
354
355
355
0 commit comments