@@ -89,6 +89,30 @@ def create_article(self, article_name, parent_id=None, content=None):
8989
9090 return article
9191
92+ def get_export_stream (self , paperSize = "A4" , exportAttachment = False ):
93+ """
94+ Download the whole wiki of the project in PDF format as a binary stream.
95+ Warning: this stream will monopolize the DSSClient until closed.
96+ """
97+ body = {
98+ "paperSize" : paperSize ,
99+ "exportAttachment" : exportAttachment
100+ }
101+ return self .client ._perform_raw ("POST" , "/projects/%s/wiki/actions/export" % (self .project_key , self .article_id ), body = body )
102+
103+ def export_to_file (self , path , paperSize = "A4" , exportAttachment = False ):
104+ """
105+ Download the whole wiki of the project in PDF format into the given output file.
106+ """
107+ stream = self .get_export_stream (paperSize = paperSize , exportAttachment = exportAttachment )
108+
109+ with open (path , 'wb' ) as f :
110+ for chunk in stream .iter_content (chunk_size = 10000 ):
111+ if chunk :
112+ f .write (chunk )
113+ f .flush ()
114+ stream .close ()
115+
92116class DSSWikiSettings (object ):
93117 """
94118 Global settings for the wiki, including taxonomy. Call save() to save
@@ -247,22 +271,23 @@ def get_uploaded_file(self, upload_id):
247271 """
248272 return self .client ._perform_raw ("GET" , "/projects/%s/wiki/%s/uploads/%s" % (self .project_key , self .article_id , upload_id ))
249273
250- def get_export_stream (self , paperSize = "A4" , exportChildren = False ):
274+ def get_export_stream (self , paperSize = "A4" , exportChildren = False , exportAttachment = False ):
251275 """
252276 Download an article in PDF format as a binary stream.
253277 Warning: this stream will monopolize the DSSClient until closed.
254278 """
255279 body = {
256280 "paperSize" : paperSize ,
257- "exportChildren" : exportChildren
281+ "exportChildren" : exportChildren ,
282+ "exportAttachment" : exportAttachment
258283 }
259284 return self .client ._perform_raw ("POST" , "/projects/%s/wiki/%s/actions/export" % (self .project_key , self .article_id ), body = body )
260285
261- def export_to_file (self , path , paperSize = "A4" , exportChildren = False ):
286+ def export_to_file (self , path , paperSize = "A4" , exportChildren = False , exportAttachment = False ):
262287 """
263288 Download an article in PDF format into the given output file.
264289 """
265- stream = self .get_export_stream (paperSize = paperSize , exportChildren = exportChildren )
290+ stream = self .get_export_stream (paperSize = paperSize , exportChildren = exportChildren , exportAttachment = exportAttachment )
266291
267292 with open (path , 'wb' ) as f :
268293 for chunk in stream .iter_content (chunk_size = 10000 ):
0 commit comments