templatepptx


Nametemplatepptx JSON
Version 0.0.8 PyPI version JSON
download
home_page
SummaryUse template PowerPoint files to generate new PowerPoint files bases on dictionary values and magic words. Dynamically generate tables, replace text and pictures.
upload_time2023-01-06 18:29:42
maintainer
docs_urlNone
author
requires_python>=3.7.10
license
keywords powerpoint pptx template
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Downloads](https://pepy.tech/badge/templatepptx)](https://pepy.tech/project/templatepptx)

# Description

Use PowerPoint templates to generate PowerPoint files based on PowerPoint templates. The PowerPoints are generated on the fly using "magic words". Magic words are specified by using the `$` sign symbol. You can specify magic words in PowerPoint templates by wrapping the word like `$this$`. Pictures can also be used as templates and are specified by defining the key words in the alt text of the picture. This tool is simple to run and setup. 

The data is populated by using a "context" object. A context object is a dictionary which contains the keywords and thier values that are used to populate the powerpoint. Additionally, tables can be populated with an unlmited number of related data by specifying a list of dictionaries in your context. A related table variable is specified in the template by adding the prefix "relationship_" to the front of the key. Please observe the following example of a context object below.

## How to Install 
`pip install templatepptx`

## Parsing Quick Start

To run this tool you will need a template PowerPoint that contains slides that have magic keywords. You will need a context file with the key words and you will need a valid PPTX file path for the output.

```
import templatepptx

input_pptx = "path//to//input.pptx"
output_pptx = "path//to//output.pptx"
context = {
    "first_name" : "John",
    "last_name" : "Smith",
    "language" : "Python",
    "title" : "PPT Tool",
    "italics" : "italics",
    "feeling" : "happy",
    "example_photo" : "path/to/example/photo.png"
    "relationship_name" : [ # This key contains the list which can contain an unlimited amount of records to populate a table.
    {
        "id" : "1",
        "first_name" : "Duncan",
        "last_name" : "Junior"},
    {
        "id" : "2",
        "first_name" : "Jessica",
        "last_name" : "Jones"}]
    }

# Read in PowerPoint and Context. Also assign what the special character is.
powerpoint = templatepptx.templatePptx(input_pptx, context, output_pptx, "$")

# Parses and exports the PowerPoint with filled out values and pictures
powerpoint.parse_template_pptx()

```

## Combining Slides Quickstart

You can generate many similar output products from a group of templates and then combining these outputs into one final product. There is an automated function built into this module which permits you to point to a whole direct, scrape all of the .pptx files and then combine them into one .pptx file. 

```
import templatepptx
in_dir = "path//to//input_dir"
out_combined = "path//to//combined_output.pptx"
templatepptx.batchTool(in_dir, out_combined).combine_slides():
```

# Documentation

## templatepptx module

##### Class `templatepptx.templatePptx(ppt, context, output_path, special_character="$")`

*Description:*
Initializes templatePptx currently provides the ability to completely parse through a template PowerPoint and replace the magic words, tables and pictures with the desired data from the context.

*Class Parameters:*
-   `ppt` : File path to template PowerPoint to parse (This file must exist). Required.
-   `context` : Dictionary containing key pair values for magic words and their new desired value. Required.
-   `output_path` : File path to the location where parsed PowerPoint will be written to. Required.
-   `special_character` : Special character which is wrapped around key words. The special character is not required and defaults to `$`. Example: `$this$`. If dollar signs do not suffice, it can be changed. Optional.

*Methods:*
-   `templatepptx.templatePptx.parse_template_pptx()` Runs method from templatePptx to parse the template.

*Properties:*
-   `context` Getter and Setter to change and view Context on the fly


*Example:*
```
import templatepptx

# Initialize templatePptx class
ppt = "path/to/template.pptx"
context = {"template_word" : "desired_new_value",
            "alt_text_key" : "path/to/image.jpg"}
output_path = "path/to/new/output.pptx"
powerpoint_template = templatepptx.templatePptx(ppt, context, output_path, special_character="$")

# Parse template
powerpoint_template.parse_template_pptx()
```

##### Class `templatepptx.batchTool(pptx_dir, output_pptx)`

*Description:*
Initalizes the batch tool to combine PowerPoints. 

*Class Parameters:*
-   `pptx_dir` : Directory path to the directory containing multiple PowerPoint files to be combined.
-   `output_pptx` : File path to the desired output location of the combined PowerPoint.

*Methods:*
-   `templatepptx.batchTool.combine_slides()` Runs the method to combine slides and output all slides into one PPTX. 
    - `is_numeric` : Boolean which defaults to True. Combine slides will attempt to combine slides in the correct numerical order that contain only numeric digits such as 1, 2 or 3. For examples, the following directory containing 1.pptx, 4.pptx and 2.pptx will be combined using slides from 1 first, 2 second and 4 last.
    - `specify_master` : A file path which specifies if a blank master deck exists. Defaults to None and creates a blank template for you. Allows for slide masters to be used which contain certain themes that will persist when combining slides. Text and images on a slide master will NOT be parsed and will remain intact. ONLY blank slide templates are used to create and copy PowerPoint templates, therefore only the blank Slide Master slide will be seen in the end product. 

## Future Planned Features
- ArcGIS Feature Service Support (Ask as needed)
- MSSQL support


## Example

Example input slides.
![input slide 1 example](img/in1.PNG)
![input slide 2 example](img/in2.PNG)

Example output slides.
![output slide 1 example](img/out1.PNG)
![output slide 2 example](img/out2.PNG)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "templatepptx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.10",
    "maintainer_email": "",
    "keywords": "powerpoint,pptx,template",
    "author": "",
    "author_email": "Samir Sellars <samir.sellars@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/57/98/ec4687f7252f8abc1886ec393b0fc5ad06bf64e04bfec50f55c9305afc31/templatepptx-0.0.8.tar.gz",
    "platform": null,
    "description": "[![Downloads](https://pepy.tech/badge/templatepptx)](https://pepy.tech/project/templatepptx)\r\n\r\n# Description\r\n\r\nUse PowerPoint templates to generate PowerPoint files based on PowerPoint templates. The PowerPoints are generated on the fly using \"magic words\". Magic words are specified by using the `$` sign symbol. You can specify magic words in PowerPoint templates by wrapping the word like `$this$`. Pictures can also be used as templates and are specified by defining the key words in the alt text of the picture. This tool is simple to run and setup. \r\n\r\nThe data is populated by using a \"context\" object. A context object is a dictionary which contains the keywords and thier values that are used to populate the powerpoint. Additionally, tables can be populated with an unlmited number of related data by specifying a list of dictionaries in your context. A related table variable is specified in the template by adding the prefix \"relationship_\" to the front of the key. Please observe the following example of a context object below.\r\n\r\n## How to Install \r\n`pip install templatepptx`\r\n\r\n## Parsing Quick Start\r\n\r\nTo run this tool you will need a template PowerPoint that contains slides that have magic keywords. You will need a context file with the key words and you will need a valid PPTX file path for the output.\r\n\r\n```\r\nimport templatepptx\r\n\r\ninput_pptx = \"path//to//input.pptx\"\r\noutput_pptx = \"path//to//output.pptx\"\r\ncontext = {\r\n    \"first_name\" : \"John\",\r\n    \"last_name\" : \"Smith\",\r\n    \"language\" : \"Python\",\r\n    \"title\" : \"PPT Tool\",\r\n    \"italics\" : \"italics\",\r\n    \"feeling\" : \"happy\",\r\n    \"example_photo\" : \"path/to/example/photo.png\"\r\n    \"relationship_name\" : [ # This key contains the list which can contain an unlimited amount of records to populate a table.\r\n    {\r\n        \"id\" : \"1\",\r\n        \"first_name\" : \"Duncan\",\r\n        \"last_name\" : \"Junior\"},\r\n    {\r\n        \"id\" : \"2\",\r\n        \"first_name\" : \"Jessica\",\r\n        \"last_name\" : \"Jones\"}]\r\n    }\r\n\r\n# Read in PowerPoint and Context. Also assign what the special character is.\r\npowerpoint = templatepptx.templatePptx(input_pptx, context, output_pptx, \"$\")\r\n\r\n# Parses and exports the PowerPoint with filled out values and pictures\r\npowerpoint.parse_template_pptx()\r\n\r\n```\r\n\r\n## Combining Slides Quickstart\r\n\r\nYou can generate many similar output products from a group of templates and then combining these outputs into one final product. There is an automated function built into this module which permits you to point to a whole direct, scrape all of the .pptx files and then combine them into one .pptx file. \r\n\r\n```\r\nimport templatepptx\r\nin_dir = \"path//to//input_dir\"\r\nout_combined = \"path//to//combined_output.pptx\"\r\ntemplatepptx.batchTool(in_dir, out_combined).combine_slides():\r\n```\r\n\r\n# Documentation\r\n\r\n## templatepptx module\r\n\r\n##### Class `templatepptx.templatePptx(ppt, context, output_path, special_character=\"$\")`\r\n\r\n*Description:*\r\nInitializes templatePptx currently provides the ability to completely parse through a template PowerPoint and replace the magic words, tables and pictures with the desired data from the context.\r\n\r\n*Class Parameters:*\r\n-   `ppt` : File path to template PowerPoint to parse (This file must exist). Required.\r\n-   `context` : Dictionary containing key pair values for magic words and their new desired value. Required.\r\n-   `output_path` : File path to the location where parsed PowerPoint will be written to. Required.\r\n-   `special_character` : Special character which is wrapped around key words. The special character is not required and defaults to `$`. Example: `$this$`. If dollar signs do not suffice, it can be changed. Optional.\r\n\r\n*Methods:*\r\n-   `templatepptx.templatePptx.parse_template_pptx()` Runs method from templatePptx to parse the template.\r\n\r\n*Properties:*\r\n-   `context` Getter and Setter to change and view Context on the fly\r\n\r\n\r\n*Example:*\r\n```\r\nimport templatepptx\r\n\r\n# Initialize templatePptx class\r\nppt = \"path/to/template.pptx\"\r\ncontext = {\"template_word\" : \"desired_new_value\",\r\n            \"alt_text_key\" : \"path/to/image.jpg\"}\r\noutput_path = \"path/to/new/output.pptx\"\r\npowerpoint_template = templatepptx.templatePptx(ppt, context, output_path, special_character=\"$\")\r\n\r\n# Parse template\r\npowerpoint_template.parse_template_pptx()\r\n```\r\n\r\n##### Class `templatepptx.batchTool(pptx_dir, output_pptx)`\r\n\r\n*Description:*\r\nInitalizes the batch tool to combine PowerPoints. \r\n\r\n*Class Parameters:*\r\n-   `pptx_dir` : Directory path to the directory containing multiple PowerPoint files to be combined.\r\n-   `output_pptx` : File path to the desired output location of the combined PowerPoint.\r\n\r\n*Methods:*\r\n-   `templatepptx.batchTool.combine_slides()` Runs the method to combine slides and output all slides into one PPTX. \r\n    - `is_numeric` : Boolean which defaults to True. Combine slides will attempt to combine slides in the correct numerical order that contain only numeric digits such as 1, 2 or 3. For examples, the following directory containing 1.pptx, 4.pptx and 2.pptx will be combined using slides from 1 first, 2 second and 4 last.\r\n    - `specify_master` : A file path which specifies if a blank master deck exists. Defaults to None and creates a blank template for you. Allows for slide masters to be used which contain certain themes that will persist when combining slides. Text and images on a slide master will NOT be parsed and will remain intact. ONLY blank slide templates are used to create and copy PowerPoint templates, therefore only the blank Slide Master slide will be seen in the end product. \r\n\r\n## Future Planned Features\r\n- ArcGIS Feature Service Support (Ask as needed)\r\n- MSSQL support\r\n\r\n\r\n## Example\r\n\r\nExample input slides.\r\n![input slide 1 example](img/in1.PNG)\r\n![input slide 2 example](img/in2.PNG)\r\n\r\nExample output slides.\r\n![output slide 1 example](img/out1.PNG)\r\n![output slide 2 example](img/out2.PNG)\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Use template PowerPoint files to generate new PowerPoint files bases on dictionary values and magic words. Dynamically generate tables, replace text and pictures.",
    "version": "0.0.8",
    "split_keywords": [
        "powerpoint",
        "pptx",
        "template"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ff7a5e0e554e8c7e579edc98f4f81dd65f1989b8e21c3bb4449766151611c70",
                "md5": "42f009e91d797bd68158a31bfafde6dc",
                "sha256": "19567f80061c1109c6b11dd5d2b68c16703554e656f33d49e4f0572fc38e2078"
            },
            "downloads": -1,
            "filename": "templatepptx-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42f009e91d797bd68158a31bfafde6dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.10",
            "size": 11071,
            "upload_time": "2023-01-06T18:29:40",
            "upload_time_iso_8601": "2023-01-06T18:29:40.365090Z",
            "url": "https://files.pythonhosted.org/packages/1f/f7/a5e0e554e8c7e579edc98f4f81dd65f1989b8e21c3bb4449766151611c70/templatepptx-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5798ec4687f7252f8abc1886ec393b0fc5ad06bf64e04bfec50f55c9305afc31",
                "md5": "996f2434f7c245d605c78fec2dd0707b",
                "sha256": "385df2b4860b33d5d5cd9e5b9346ffc94610e96177686cd1422208a372a65613"
            },
            "downloads": -1,
            "filename": "templatepptx-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "996f2434f7c245d605c78fec2dd0707b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.10",
            "size": 8447,
            "upload_time": "2023-01-06T18:29:42",
            "upload_time_iso_8601": "2023-01-06T18:29:42.372812Z",
            "url": "https://files.pythonhosted.org/packages/57/98/ec4687f7252f8abc1886ec393b0fc5ad06bf64e04bfec50f55c9305afc31/templatepptx-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-06 18:29:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "templatepptx"
}
        
Elapsed time: 0.02442s