@@ -80,9 +80,9 @@ def find_template_file(template_name):
80
80
def _convert_file (filename , format , result_queue = None , options = None ):
81
81
"""Helper function to convert a file via LOKit.
82
82
83
- This function can be called via subprocess so that in the event of LO crashing randomly
84
- after conversion, it will not terminate the parent process. This is assisted by inserting
85
- the result into a Queue object.
83
+ This function can be called via subprocess so that in the event of LO
84
+ crashing randomly after conversion, it will not terminate the parent
85
+ process. This is assisted by inserting the result into a Queue object.
86
86
"""
87
87
lo_path = getattr (
88
88
settings ,
@@ -96,25 +96,34 @@ def _convert_file(filename, format, result_queue=None, options=None):
96
96
doc .saveAs (str (conv_file .name ), options = options )
97
97
os .unlink (filename )
98
98
99
- # type comparison is required instead of isinstance owing to multiprocessing.Queue is a method
99
+ # type comparison is required instead of isinstance owing to
100
+ # multiprocessing.Queue is a method
100
101
if type (result_queue ) == multiprocessing .queues .Queue :
101
102
result_queue .put (conv_file .name )
102
103
else :
103
104
return conv_file .name
104
105
105
106
106
- def fill_template (template_name , context , output_format = 'odt' , options = None , separate_process = True ):
107
+ def fill_template (
108
+ template_name ,
109
+ context ,
110
+ output_format = 'odt' ,
111
+ options = None ,
112
+ separate_process = True ,
113
+ ):
107
114
"""Fill a document with data and convert it to the requested format.
108
115
109
116
Returns an absolute path to the generated file.
110
117
111
118
Supported output format:
112
119
Text documents: doc, docx, fodt, html, odt, ott, pdf, txt, xhtml, png
113
120
Spreadsheets: csv, fods, html, ods, ots, pdf, xhtml, xls, xlsx, png
114
- Presentations: fodp, html, odg, odp, otp, pdf, potm, pot, pptx, pps, ppt, svg, swf, xhtml, png
121
+ Presentations: fodp, html, odg, odp, otp, pdf, potm, pot, pptx, pps,
122
+ ppt, svg, swf, xhtml, png
115
123
Drawings: fodg, html, odg, pdf, svg, swf, xhtml, png
116
124
117
- More on filter options, https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options
125
+ More on filter options,
126
+ https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options # noqa: E501
118
127
119
128
:param template_name: the path to template, in OpenDocument format
120
129
:param context: the context to be used to inject content
@@ -171,8 +180,10 @@ def fill_template(template_name, context, output_format='odt', options=None, sep
171
180
if source_extension [1 :] != output_format :
172
181
if separate_process :
173
182
results = multiprocessing .Queue ()
174
- converter = multiprocessing .Process (target = _convert_file ,
175
- args = (str (dest_file .name ), output_format , results , options ))
183
+ converter = multiprocessing .Process (
184
+ target = _convert_file ,
185
+ args = (str (dest_file .name ), output_format , results , options ),
186
+ )
176
187
converter .start ()
177
188
return results .get ()
178
189
else :
0 commit comments