A Python library with various tools for enhancing python-pptx.
import pptxpy
This import
attaches several methods to certain classes from python-pptx,
implementing additional functionality (like cloning).
Slides.duplicate(self, [slide_index: int], [slide_id: str])
-
Creates an identical copy of the
Slide
instance (given by eitherslide_index
orslide_id
) by cloning its correspondingSlidePart
instance, then appends it toself
. Return value: The newly createdSlide
instance. Part.clone(self, [uri: PackURI], [cloner: Cloner])
-
Creates an exact copy of this
Part
instance. The new instance’spartname
becomesuri
if non-null, otherwiseself.partname
. The cloning process is performed recursively on all related parts, with the exception of the already cloned parts (stored incloner._cache
); however, ifcloner is None
thenself
is copied alone, without recursion. Return value: The newly createdPart
instance. Part.is_similar(self, other)
-
Essentially performs shallow structural equality testing between
self
andother
- with the exception ofpartname
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 havingpartname
assigned the value ofuri
(if non-null), otherwiseself.partname
. Return value: The newly createdPart
instance. RelationshipCollection.append(self, rel: _Relationship)
-
Creates a new
_Relationship
instance based onrel
and inserts it intoself
. Return value: A Boolean value indicating whetherrel is None
. RelationshipCollection.attach(self, rel: _Relationship)
-
Inserts
rel
intoself
, performing additional necessary bindings. Return value:rel.target_part
. RelationshipCollection.eq(self, other)
-
Performs structural equality testing between
self
andother
. 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 clonedPart
instances - thus avoiding infinite recursion.
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.