@@ -89,6 +89,28 @@ def create_article(self, article_name, parent_id=None, content=None):
8989
9090 return article
9191
92+ def get_export_stream (self , paper_size = "A4" , export_attachment = 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" : paper_size ,
99+ "exportAttachment" : export_attachment
100+ }
101+ return self .client ._perform_raw ("POST" , "/projects/%s/wiki/actions/export" % (self .project_key ), body = body )
102+
103+ def export_to_file (self , path , paper_size = "A4" , export_attachment = False ):
104+ """
105+ Download the whole wiki of the project in PDF format into the given output file.
106+ """
107+ with self .get_export_stream (paper_size = paper_size , export_attachment = export_attachment ) as stream :
108+ with open (path , 'wb' ) as f :
109+ for chunk in stream .iter_content (chunk_size = 10000 ):
110+ if chunk :
111+ f .write (chunk )
112+ f .flush ()
113+
92114class DSSWikiSettings (object ):
93115 """
94116 Global settings for the wiki, including taxonomy. Call save() to save
@@ -250,6 +272,30 @@ def get_uploaded_file(self, upload_id):
250272 """
251273 return self .client ._perform_raw ("GET" , "/projects/%s/wiki/%s/uploads/%s" % (self .project_key , self .article_id , upload_id ))
252274
275+ def get_export_stream (self , paper_size = "A4" , export_children = False , export_attachment = False ):
276+ """
277+ Download an article in PDF format as a binary stream.
278+ Warning: this stream will monopolize the DSSClient until closed.
279+ """
280+ body = {
281+ "paperSize" : paper_size ,
282+ "exportChildren" : export_children ,
283+ "exportAttachment" : export_attachment
284+ }
285+ return self .client ._perform_raw ("POST" , "/projects/%s/wiki/%s/actions/export" % (self .project_key , self .article_id ), body = body )
286+
287+ def export_to_file (self , path , paper_size = "A4" , export_children = False , export_attachment = False ):
288+ """
289+ Download an article in PDF format into the given output file.
290+ """
291+ with self .get_export_stream (paper_size = paper_size , export_children = export_children , export_attachment = export_attachment ) as stream :
292+ with open (path , 'wb' ) as f :
293+ for chunk in stream .iter_content (chunk_size = 10000 ):
294+ if chunk :
295+ f .write (chunk )
296+ f .flush ()
297+
298+
253299 def delete (self ):
254300 """
255301 Delete the article
0 commit comments