Package: sliger
sligerSlide of the tigerSlide the power of Python (and Jinja2) into Google SlidesInstallpip install sligerPrerequisitesTo usesligerwith a specific Google Slides presentation, the following is necessary:Keys to a GCP Service Account (a.jsonfile)The presentation needs to be shared with the email that can be found in 1.UsageIn general,sligerneeds two pieces of information in order for it to
do any automation on a specific Google Slides presentation:The credentials file (the first point in the previous section)The Presentation ID (assuming the presentation can be found athttps://docs.google.com/presentation/d/1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ/editthe presentation ID would be1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ)There are quite a few commands that thesligersupports:duplicate-presentationTo duplicate a specific presentation (in this case the presentation with the ID1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ) to a new one with a specific name (in this case'A new presentation test'), one could run the following command:sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ duplicate-presentation --copy-title 'A new presentation test'delete-slideTo delete slide number 3, one can run the following:sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ delete-slide --id 3duplicate-slideTo duplicate slide number 3, one can run the following:sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ duplicate-slide --id 3jinjifysligeralso supportsJinja Templates.It also provides a few custom functions, such asstrftimewhich can be used to format dates. For instance the stringHi! Today is {{ strftime("%A, %O %B", now) }}Would get rendered toHi! Today is Friday, 2nd SeptemberJinjify is also able to render Python functions. Once added the function tocollector.pyand to the variablefunc_dict,jinjifywill parse the Python output in plain text.
For instance the string:{{ greet_pycon() }}Would get render toHi PyCon Italy! This string is generated from a Python function.To render the template directly inside a specific presentation, you can runsliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ jinjifyNote that for the apostrophes to be picked up correctly, you will need to turn off theUse smart quotesoption inTools -> Preferences, as described in thecommunity docs.imagifyLooks for text elements whose content is in the following format:![image](<IMAGE_PATH>)It then replaces the found text elements with image elements containing the images found atIMAGE_PATH. The image needs to be present locally. TheIMAGE_PATHcan be templated with
Jinja. The used Jinja function should return the path to a locally present image that should be
uploaded.For example the following text placeholder will call thegenerate_imageJinja function which
should create an image on the disk and return the path to the image.![image]({{ generate_image }})To replace the placeholders with actual images in the presentation, one can run:sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ imagify