Skip to main content

Slide the power of Python (and Jinja2) into Google Slides

Project description

sliger

Slide of the tiger Slide the power of Python (and Jinja2) into Google Slides

PyPI License: Apache 2.0 Scc Count Badge Scc Count Badge

Install

pip install sliger

Prerequisites

To use sliger with a specific Google Slides presentation, the following is necessary:

  1. Keys to a GCP Service Account (a .json file)
  2. The presentation needs to be shared with the email that can be found in 1.

Usage

In general, sliger needs two pieces of information in order for it to do any automation on a specific Google Slides presentation:

  1. The credentials file (the first point in the previous section)
  2. The Presentation ID (assuming the presentation can be found at https://docs.google.com/presentation/d/1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ/edit the presentation ID would be 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ)

There are quite a few commands that the sliger supports:

duplicate-presentation

To duplicate a specific presentation (in this case the presentation with the ID 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ) 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-slide

To delete slide number 3, one can run the following:

sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ delete-slide --id 3

duplicate-slide

To duplicate slide number 3, one can run the following:

sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ duplicate-slide --id 3

jinjify

sliger also supports Jinja Templates.

It also provides a few custom functions, such as strftime which can be used to format dates. For instance the string

Hi! Today is {{ strftime("%A, %O %B", now) }}

Would get rendered to

Hi! Today is Friday, 2nd September

Jinjify is also able to render Python functions. Once added the function to collector.py and to the variable func_dict, jinjify will parse the Python output in plain text. For instance the string:

{{ greet_pycon() }}

Would get render to

Hi PyCon Italy! This string is generated from a Python function.

To render the template directly inside a specific presentation, you can run

sliger --creds-file mrshu-gslidesexperiments-7cd84ace2933.json --presentation-id 1ijjVtlf9Jq1Rr0xTOMZWcSAUbfl6oA1aaBickwpUdGQ jinjify

Note that for the apostrophes to be picked up correctly, you will need to turn off the Use smart quotes option in Tools -> Preferences, as described in the community docs.

imagify

Looks 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 at IMAGE_PATH. The image needs to be present locally. The IMAGE_PATH can 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 the generate_image Jinja 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sliger-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

sliger-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file sliger-0.1.0.tar.gz.

File metadata

  • Download URL: sliger-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.10.11 Darwin/22.4.0

File hashes

Hashes for sliger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1f3417ad59a9821e78503b1611673b989d0368837810ba47e2033b23032f596
MD5 925445bbc5e7a4b96f187a55a0117b05
BLAKE2b-256 beb826e9e8408f55a390abe7b907807dca9bc704ab16c3214d880b917f1faf88

See more details on using hashes here.

File details

Details for the file sliger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sliger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.10.11 Darwin/22.4.0

File hashes

Hashes for sliger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13dfd3e943b3d9cdb4cad2fa51cd205aa03594f1d62c973f926e42fd163e5ee9
MD5 3ba2ad79e06663b559c15c3053208e58
BLAKE2b-256 e42053bd14e3ace9406ba564ad07ace67dc85bf3fa1fc3ac7a5e1adca2e12d89

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page