Skip to content

A set of useful tools for enhancing python-pptx

License

Notifications You must be signed in to change notification settings

denim2x/pptx-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pptx-py

A Python library with various tools for enhancing python-pptx.

Usage

import pptxpy

This import attaches several methods to certain classes from python-pptx, implementing additional functionality (like cloning).

Documentation

Slides.duplicate(self, [slide_index: int], [slide_id: str])

Creates an identical copy of the Slide instance (given by either slide_index or slide_id) by cloning its corresponding SlidePart instance, then appends it to self. Return value: The newly created Slide instance.

Part.clone(self, [uri: PackURI], [cloner: Cloner])

Creates an exact copy of this Part instance. The new instance’s partname becomes uri if non-null, otherwise self.partname. The cloning process is performed recursively on all related parts, with the exception of the already cloned parts (stored in cloner._cache); however, if cloner is None then self is copied alone, without recursion. Return value: The newly created Part instance.

Part.is_similar(self, other)

Essentially performs shallow structural equality testing between self and other - with the exception of partname which is tested for similarity rather then equality. Return value: The Boolean result of the tests.

Part._clone(self, [uri: PackURI])

Creates a shallow duplicate of self, optionally having partname assigned the value of uri (if non-null), otherwise self.partname. Return value: The newly created Part instance.

RelationshipCollection.append(self, rel: _Relationship)

Creates a new _Relationship instance based on rel and inserts it into self. Return value: A Boolean value indicating whether rel is None.

RelationshipCollection.attach(self, rel: _Relationship)

Inserts rel into self, performing additional necessary bindings. Return value: rel.target_part.

RelationshipCollection.eq(self, other)

Performs structural equality testing between self and other. Return value: The Boolean result of the tests.

class Cloner

Utility class for handling the cloning process for a given _Relationship instance; uses a _cache to store all cloned Part instances - thus avoiding infinite recursion.

Dependencies

pptx-py does not currenly depend (explicitly) on any external packages; however, one has to ensure the presence of python-pptx in order to work with this library.

License