Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pptx_template/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def remove_all_slides_having_id(presentation):
unused_slides = []
for slide in presentation.slides:
for shape in txt.select_all_text_shapes(slide):
slide_id = txt.extract_slide_id(shape.text)
slide_id = None
if hasattr(shape, 'text'):
slide_id = txt.extract_slide_id(shape.text)
if slide_id:
unused_slides.append((slide_id, slide))
break
Expand All @@ -96,6 +98,6 @@ def get_slide(presentation, slide_id):
"""
for slide in presentation.slides:
for shape in txt.select_all_text_shapes(slide):
if txt.extract_slide_id(shape.text) == slide_id:
if hasattr(shape, 'text') and txt.extract_slide_id(shape.text) == slide_id:
return slide
raise ValueError(u"slide id:%s not found" % slide_id)
9 changes: 8 additions & 1 deletion pptx_template/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def search_first_el(text):


def select_all_text_shapes(slide):
return [ s for s in slide.shapes if s.shape_type in [1,14,17] ]
collect = []
for s in slide.shapes:
try:
if s.shape_type in [1, 14, 17]:
collect.append(s)
except Exception as err:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TRANTANKHOA
[ASK] Is this intending to catch AttributeError for s.shape_type ?
I think catching Exception is too broad and wondering if we can use if statement ( e.g. if hasattr(s, 'shape_type') )

print(err)
return collect


def select_all_tables(slide):
Expand Down