Ejemplo n.º 1
0
image_dir = argv[3]
text_colour = argv[4]
aspect_ratio = argv[5]

# Get all pptx files and image files
pptx_file_dir = list_filenames(extract_dir, 'pptx')
# pptx_file_names = filenames_only(pptx_file_dir)
pptx_file_names = list(map(lambda x: basename(x), pptx_file_dir))
images_path = list_filenames(image_dir, 'jpg')

# List of hymns
hymns = []

# Change colour, normally black if none supplied
text_colour = RGBColor(
    255, 255, 255) if text_colour.lower() == 'white' else RGBColor(0, 0, 0)

# Extract the hymn texts into a list of strings
for i in range(len(pptx_file_dir)):
    current_hymn = []
    prs = Presentation(pptx_file_dir[i])

    # Choose only objects which have text
    for slide in prs.slides:
        for shape in slide.shapes:
            if not shape.has_text_frame:
                continue
            if not shape.text.strip() == '':
                # current_hymn.append(shape.text)
                current_hymn.append(
                    sub(