Commits

Martin Ostrovsky committed 22dea5e

put in an assertion to ensure supplied lists are the same length

Comments (0)

Files changed (2)

python/repustate.py

         """
         return self._call_api('extract-dates', text=text)
 
-    def powerpoint(self, report_title, author, images, titles):
+    def powerpoint(self, report_title, author, images, titles, notes):
         """
-        Given a list of images and titles, generate a simple powerpoint presentation.
+        Given a sorted list of images, titles and notes, generate a simple powerpoint presentation.
+
+        The length of each list must be the same.
         """
         kwargs = dict(
             title=report_title,
             author=author,
         )
 
-        for idx, (image, title) in enumerate(zip(images, titles)):
+        assert len(images) == len(titles) == len(notes), "The lists of images, titles, and notes supplied must all be the same length."
+
+        for idx, (image, title, note) in enumerate(zip(images, titles, notes)):
             # We need to b64 encode the image.
             image_content = base64.b64encode(open(image).read())
             kwargs['slide_%d_image' % idx] = image_content
             kwargs['slide_%d_title' % idx] = title
+            kwargs['slide_%d_notes' % idx] = note
 
         return self._call_api('powerpoint', **kwargs)
 
     # To make this example work, you'll have to have an image called 'test.jpg'
     # in this directory. A new power point presentation called "Test.ppt" will
     # be saved in the current directory.
-    data = client.powerpoint('Test Report', 'Martin Ostrovsky', images=['test.jpg'], titles=['A test title'])
+    data = client.powerpoint('Test Report', 'Martin Ostrovsky', images=['test.jpg'], titles=['A test title'], notes=['What a pretty slide.'])
     fd = open('Test.ppt', 'w')
     fd.write(data)
     fd.close()

python/test_repustate.py

             author='Martin Ostrovsky',
             images=['repustate.gif'],
             titles=['A test title'],
+            notes=['What a pretty slide.'],
             )
         self.check_call('powerpoint', check_status=False, **kwargs)