Force to use python-docx 0.8.7

This commit is contained in:
elapouya 2019-01-11 15:13:11 +01:00
parent 651b59fc21
commit 12e709f80b
3 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,8 @@
0.5.16 (2019-01-11)
-------------------
- Force to use python-docx 0.8.7 (#170)
- Add getting undeclared variables in the template (#171)
0.5.15 (2019-01-02) 0.5.15 (2019-01-02)
------------------- -------------------
- Added `PAGE_BREAK` feature (#168) - Added `PAGE_BREAK` feature (#168)

View File

@ -6,7 +6,7 @@ Created : 2015-03-12
''' '''
import functools import functools
__version__ = '0.5.15' __version__ = '0.5.16'
from lxml import etree from lxml import etree
from docx import Document from docx import Document
@ -41,14 +41,6 @@ class DocxTemplate(object):
HEADER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" HEADER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
FOOTER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" FOOTER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
@property
def undeclared_template_variables(self):
xml = self.get_xml()
xml = self.patch_xml(xml)
env = Environment()
parse_content = env.parse(xml)
return meta.find_undeclared_variables(parse_content)
def __init__(self, docx): def __init__(self, docx):
self.docx = Document(docx) self.docx = Document(docx)
self.crc_to_new_media = {} self.crc_to_new_media = {}
@ -564,6 +556,14 @@ class DocxTemplate(object):
self.docx.save(filename,*args,**kwargs) self.docx.save(filename,*args,**kwargs)
self.post_processing(filename) self.post_processing(filename)
@property
def undeclared_template_variables(self):
xml = self.get_xml()
xml = self.patch_xml(xml)
env = Environment()
parse_content = env.parse(xml)
return meta.find_undeclared_variables(parse_content)
class Subdoc(object): class Subdoc(object):
""" Class for subdocument to insert into master document """ """ Class for subdocument to insert into master document """

View File

@ -53,7 +53,10 @@ setup(name='docxtpl',
author_email='elapouya@gmail.com', author_email='elapouya@gmail.com',
license='LGPL 2.1', license='LGPL 2.1',
packages=['docxtpl'], packages=['docxtpl'],
install_requires=['six', 'python-docx', 'jinja2', 'lxml'], install_requires=['six',
'python-docx<=0.8.7', # newer docx package breaks header/footer management in docxtpl
'jinja2',
'lxml'],
extras_require={'docs': ['Sphinx', 'sphinxcontrib-napoleon']}, extras_require={'docs': ['Sphinx', 'sphinxcontrib-napoleon']},
eager_resources=['docs'], eager_resources=['docs'],
zip_safe=False) zip_safe=False)