Add type hints to get_undeclared_template_variables
This commit is contained in:
parent
2681c4801d
commit
43ceb38465
@ -6,7 +6,7 @@ Created : 2015-03-12
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from os import PathLike
|
from os import PathLike
|
||||||
from typing import Any, Optional, IO, Union, Dict
|
from typing import Any, Optional, IO, Union, Dict, Set
|
||||||
from .subdoc import Subdoc
|
from .subdoc import Subdoc
|
||||||
import functools
|
import functools
|
||||||
import io
|
import io
|
||||||
@ -36,7 +36,7 @@ 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"
|
||||||
|
|
||||||
def __init__(self, template_file_or_path: Union[IO[bytes], str, PathLike[str]]):
|
def __init__(self, template_file_or_path: Union[IO[bytes], str, PathLike[str]]) -> None:
|
||||||
self.template_file_or_path = template_file_or_path
|
self.template_file_or_path = template_file_or_path
|
||||||
self.reset_replacements()
|
self.reset_replacements()
|
||||||
self.docx = None
|
self.docx = None
|
||||||
@ -324,7 +324,7 @@ class DocxTemplate(object):
|
|||||||
new_part.load_rel(rel.reltype, rel._target, rel.rId, rel.is_external)
|
new_part.load_rel(rel.reltype, rel._target, rel.rId, rel.is_external)
|
||||||
self.docx._part._rels[relKey]._target = new_part
|
self.docx._part._rels[relKey]._target = new_part
|
||||||
|
|
||||||
def render(self, context: Dict[str, Any], jinja_env: Optional[Environment]=None, autoescape: bool=False):
|
def render(self, context: Dict[str, Any], jinja_env: Optional[Environment]=None, autoescape: bool=False) -> None:
|
||||||
# init template working attributes
|
# init template working attributes
|
||||||
self.render_init()
|
self.render_init()
|
||||||
|
|
||||||
@ -722,7 +722,7 @@ class DocxTemplate(object):
|
|||||||
self.post_processing(output_file_or_path)
|
self.post_processing(output_file_or_path)
|
||||||
self.is_saved = True
|
self.is_saved = True
|
||||||
|
|
||||||
def get_undeclared_template_variables(self, jinja_env=None):
|
def get_undeclared_template_variables(self, jinja_env: Optional[Environment]=None) -> Set[str]:
|
||||||
self.init_docx()
|
self.init_docx()
|
||||||
xml = self.get_xml()
|
xml = self.get_xml()
|
||||||
xml = self.patch_xml(xml)
|
xml = self.patch_xml(xml)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user