use six.iteritems() instead of iteritems for python 3 compatibility

This commit is contained in:
elapouya 2017-10-13 10:04:48 +02:00
parent 992b52f223
commit 0903bf42fc
2 changed files with 7 additions and 3 deletions

View File

@ -1,3 +1,7 @@
0.4.4 (2017-10-13)
------------------
- use six.iteritems() instead of iteritems for python 3 compatibility
0.4.3 (2017-10-13) 0.4.3 (2017-10-13)
------------------ ------------------
- Fixed Bug #95 on replace_pic() method - Fixed Bug #95 on replace_pic() method

View File

@ -5,7 +5,7 @@ Created : 2015-03-12
@author: Eric Lapouyade @author: Eric Lapouyade
''' '''
__version__ = '0.4.3' __version__ = '0.4.4'
from lxml import etree from lxml import etree
from docx import Document from docx import Document
@ -277,7 +277,7 @@ class DocxTemplate(object):
self.build_pic_map() self.build_pic_map()
# Do the actual replacement # Do the actual replacement
for embedded_file,stream in self.pic_to_replace.iteritems(): for embedded_file,stream in six.iteritems(self.pic_to_replace):
if embedded_file not in self.pic_map: if embedded_file not in self.pic_map:
raise ValueError('Picture "%s" not found in the docx template' % embedded_file) raise ValueError('Picture "%s" not found in the docx template' % embedded_file)
self.pic_map[embedded_file][1]._blob=stream self.pic_map[embedded_file][1]._blob=stream
@ -290,7 +290,7 @@ class DocxTemplate(object):
self.pic_map.update(self._img_filename_to_part(part)) self.pic_map.update(self._img_filename_to_part(part))
# Header/Footer # Header/Footer
for relid, rel in self.docx.part.rels.iteritems(): for relid, rel in six.iteritems(self.docx.part.rels):
if rel.reltype in (REL_TYPE.HEADER,REL_TYPE.FOOTER): if rel.reltype in (REL_TYPE.HEADER,REL_TYPE.FOOTER):
self.pic_map.update(self._img_filename_to_part(rel.target_part)) self.pic_map.update(self._img_filename_to_part(rel.target_part))