def when_I_call_shapes_add_movie(context): shapes = context.shapes x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000) context.movie = shapes.add_movie( test_file('just-two-mice.mp4'), x, y, cx, cy, test_file('just-two-mice.png') )
def given_a_PROG_ID_member_file_as_ole_object_file(context, PROG_ID_member): filename = { "DOCX": "shp-embedded-docx.docx", "PPTX": "shp-embedded-pptx.pptx", "XLSX": "shp-embedded-xlsx.xlsx", }[PROG_ID_member] with open(test_file(filename), "rb") as f: context.ole_object_file = io.BytesIO(f.read()) context.PROG_ID_member = PROG_ID_member
def given_a_shape_having_click_action_action(context, action): shape_idx = ( "none", "first slide", "last slide", "previous slide", "next slide", "last slide viewed", "named slide", "end show", "hyperlink", "other presentation", "open file", "custom slide show", "OLE action", "run macro", "run program", "play media", ).index(action) slides = Presentation(test_file("act-props.pptm")).slides context.slides = slides context.click_action = slides[2].shapes[shape_idx].click_action
def given_image_filename(context, filename): context.image_path = test_file(filename)
def when_I_open_a_presentation_extracted_into_a_directory(context): context.prs = Presentation(test_file("extracted-pptx"))
def when_I_call_TextFrame_fit_text(context): from helpers import test_file font_file = test_file("calibriz.ttf") context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
def when_add_inline_picture_to_document(context): document = context.document run = document.add_paragraph().add_run() context.inline_shape = (document.inline_shapes.add_picture( test_file('monty-truth.png'), run))
def when_I_call_TextFrame_fit_text(context): from helpers import test_file font_file = test_file('calibriz.ttf') context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
def when_add_picture_specifying_width(context): document = context.document context.picture = document.add_picture(test_file('monty-truth.png'), width=Inches(1.5))
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context): actual_sha1 = context.movie.poster_frame.sha1 with open(test_file('just-two-mice.png'), 'rb') as f: expected_sha1 = hashlib.sha1(f.read()).hexdigest() assert actual_sha1 == expected_sha1, 'not the same image'
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context): actual_sha1 = context.movie.poster_frame.sha1 with open(test_file("just-two-mice.png"), "rb") as f: expected_sha1 = hashlib.sha1(f.read()).hexdigest() assert actual_sha1 == expected_sha1, "not the same image"
def when_I_add_a_picture_to_the_run(context): run = context.run run.add_picture(test_file('monty-truth.png'))
def when_I_call_run_add_picture(context): context.run.add_picture(test_file("test.png"))
def given_an_ActionSetting_object_as_click_action(context, action): shape_idx = {"NONE": 0, "NAMED_SLIDE": 6}[action] slides = Presentation(test_file("act-props.pptm")).slides context.slides = slides context.click_action = slides[2].shapes[shape_idx].click_action
def when_add_inline_picture_from_file_like_object(context): document = context.document run = document.add_paragraph().add_run() with open(test_file('monty-truth.png'), 'rb') as f: context.inline_shape = document.inline_shapes.add_picture(f, run)
def when_I_call_shapes_add_movie(context): shapes = context.shapes x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000) context.movie = shapes.add_movie( test_file("just-two-mice.mp4"), x, y, cx, cy, test_file("just-two-mice.png") )
def when_add_inline_picture_to_document(context): document = context.document run = document.add_paragraph().add_run() context.inline_shape = (document.inline_shapes.add_picture( test_file('monty-truth.png'), run ))
def when_add_picture_specifying_only_image_file(context): document = context.document context.picture = document.add_picture(test_file('monty-truth.png'))
def when_add_picture_specifying_width(context): document = context.document context.picture = document.add_picture( test_file('monty-truth.png'), width=Inches(1.5) )
def when_add_picture_specifying_height(context): document = context.document context.picture = document.add_picture(test_file("monty-truth.png"), height=Inches(1.5))
def when_I_call_placeholder_insert_picture(context, filename): placeholder = context.shape path = test_file(filename) with open(path, 'rb') as f: context.image_sha1 = hashlib.sha1(f.read()).hexdigest() context.placeholder = placeholder.insert_picture(path)
def when_I_call_placeholder_insert_picture(context, filename): placeholder = context.shape path = test_file(filename) with open(path, "rb") as f: context.image_sha1 = hashlib.sha1(f.read()).hexdigest() context.placeholder = placeholder.insert_picture(path)