barunsaha commited on
Commit
e819c92
1 Parent(s): 6b9738b

Prevent the addition of empty slide when the number of steps are too few or many

Browse files
Files changed (1) hide show
  1. helpers/pptx_helper.py +5 -6
helpers/pptx_helper.py CHANGED
@@ -92,8 +92,6 @@ def generate_powerpoint_presentation(
92
 
93
  # Add content in a loop
94
  for a_slide in parsed_data['slides']:
95
- # The loop has a bug:
96
- # if any of this functions fail (i.e., returns False), an empty slide would still exist
97
  is_processing_done = _handle_double_col_layout(
98
  presentation=presentation,
99
  slide_json=a_slide,
@@ -623,6 +621,11 @@ def _handle_step_by_step_process(
623
  ):
624
  return False
625
 
 
 
 
 
 
626
  bullet_slide_layout = presentation.slide_layouts[1]
627
  slide = presentation.slides.add_slide(bullet_slide_layout)
628
  shapes = slide.shapes
@@ -665,10 +668,6 @@ def _handle_step_by_step_process(
665
  shape.text = step.removeprefix(STEP_BY_STEP_PROCESS_MARKER)
666
  top += height + INCHES_0_3
667
  left += INCHES_0_5
668
- else:
669
- # Two steps -- probably not a process
670
- # More than 5--6 steps -- would likely cause a visual clutter
671
- return False
672
 
673
  return True
674
 
 
92
 
93
  # Add content in a loop
94
  for a_slide in parsed_data['slides']:
 
 
95
  is_processing_done = _handle_double_col_layout(
96
  presentation=presentation,
97
  slide_json=a_slide,
 
621
  ):
622
  return False
623
 
624
+ if n_steps < 3 or n_steps > 6:
625
+ # Two steps -- probably not a process
626
+ # More than 5--6 steps -- would likely cause a visual clutter
627
+ return False
628
+
629
  bullet_slide_layout = presentation.slide_layouts[1]
630
  slide = presentation.slides.add_slide(bullet_slide_layout)
631
  shapes = slide.shapes
 
668
  shape.text = step.removeprefix(STEP_BY_STEP_PROCESS_MARKER)
669
  top += height + INCHES_0_3
670
  left += INCHES_0_5
 
 
 
 
671
 
672
  return True
673