Conditions | 6 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import os |
||
17 | def run(self, path, slides): |
||
18 | if self.template is not None and self.template != '': |
||
19 | if os.path.exists(self.template): |
||
20 | prs = Presentation(self.template) |
||
21 | else: |
||
22 | prs = Presentation() |
||
23 | |||
24 | if not isinstance(slides, list): |
||
25 | raise InvalidActionParameterException("slides must be a list") |
||
26 | |||
27 | for slide in slides: |
||
28 | slide = prs.slides.add_slide(slide.get('layout', 1)) |
||
29 | shapes = slide.shapes |
||
30 | |||
31 | title_shape = shapes.title |
||
32 | body_shape = shapes.placeholders[1] |
||
33 | |||
34 | title_shape.text = slide.get('title', '') |
||
35 | |||
36 | tf = body_shape.text_frame |
||
37 | tf.text = slide.get('text', '') |
||
38 | |||
39 | result = prs.save(path) |
||
40 | return result |
||
41 |