
    hi                        d Z ddlmZ ddlmZmZmZ ddlmZ	 ddl
mZ ddlmZ ddlmZmZ ddlmZ dd	lmZ erdd
lmZ ddlmZmZmZmZ  G d de          ZdS )z4Presentation part, the main part in a .pptx package.    )annotations)IOTYPE_CHECKINGIterable)RELATIONSHIP_TYPE)XmlPart)PackURI)NotesMasterPart	SlidePart)Presentation)lazyproperty)CorePropertiesPart)NotesMasterSlideSlideLayoutSlideMasterc                      e Zd ZdZd dZed!d            Zd"dZed#d            Z	ed$d            Z
ed             Zd%dZd&dZd'dZd(dZd Zed             ZdS ))PresentationPartziTop level class in object model.

    Represents the contents of the /ppt directory of a .pptx file.
    slide_layoutr   c                    | j         }|j        }t          j        || j        |          }|                     |t          j                  }||j        fS )z}Return (rId, slide) pair of a newly created blank slide.

        New slide inherits appearance from `slide_layout`.
        )	_next_slide_partnamepartr   newpackage	relate_toRTSLIDEslide)selfr   partnameslide_layout_part
slide_partrIds         o/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/parts/presentation.py	add_slidezPresentationPart.add_slide   sN    
 ,(-]8T\;LMM
nnZ22J$$$    returnr   c                    | j         j        S )zA |CoreProperties| object for the presentation.

        Provides read/write access to the Dublin Core properties of this presentation.
        )r   core_propertiesr   s    r$   r)   z PresentationPart.core_properties$   s     |++r&   slide_idintSlide | Nonec                |    | j         j        D ].}|j        |k    r!|                     |j                  j        c S /dS )zReturn optional related |Slide| object identified by `slide_id`.

        Returns |None| if no slide with `slide_id` is related to this presentation.
        N)_elementsldIdLstidrelated_partr#   r   )r   r+   sldIds      r$   	get_slidezPresentationPart.get_slide,   sN    
 ]+ 	: 	:Ex8##((339999 $tr&   r   c                    | j         j        S )z
        Return the |NotesMaster| object for this presentation. If the
        presentation does not have a notes master, one is created from
        a default template. The same single instance is returned on each
        call.
        )notes_master_partnotes_masterr*   s    r$   r7   zPresentationPart.notes_master6   s     %22r&   r
   c                    	 |                      t          j                  S # t          $ r> t	          j        | j                  }|                     |t          j                   |cY S w xY w)zReturn the |NotesMasterPart| object for this presentation.

        If the presentation does not have a notes master, one is created from a default template.
        The same single instance is returned on each call.
        )part_related_byr   NOTES_MASTERKeyErrorr
   create_defaultr   r   )r   r6   s     r$   r6   z"PresentationPart.notes_master_part@   sn    	%''888 	% 	% 	% / >t| L LNN,bo>>>$$$$	%s   ! AA)(A)c                ,    t          | j        |           S )zg
        A |Presentation| object providing access to the content of this
        presentation.
        )r   r/   r*   s    r$   presentationzPresentationPart.presentationN   s     DM4000r&   r#   strr   c                6    |                      |          j        S )z?Return |Slide| object for related |SlidePart| related by `rId`.)r2   r   r   r#   s     r$   related_slidezPresentationPart.related_slideV   s      %%++r&   r   c                6    |                      |          j        S )zCReturn |SlideMaster| object for |SlideMasterPart| related by `rId`.)r2   slide_masterrA   s     r$   related_slide_masterz%PresentationPart.related_slide_masterZ   s      %%22r&   rIdsIterable[str]c                    t          |          D ]4\  }}|                     |          }t          d|dz   z            |_        5dS )a{  Assign incrementing partnames to the slide parts identified by `rIds`.

        Partnames are like `/ppt/slides/slide9.xml` and are assigned in the order their id appears
        in the `rIds` sequence. The name portion is always `slide`. The number part forms a
        continuous sequence starting at 1 (e.g. 1, 2, ... 10, ...). The extension is always
        `.xml`.
        /ppt/slides/slide%d.xml   N)	enumerater2   r	   r    )r   rF   idxr#   r"   s        r$   rename_slide_partsz#PresentationPart.rename_slide_parts^   s[     "$ 	Q 	QHC**3//J")*CsQw*O"P"PJ	Q 	Qr&   path_or_streamstr | IO[bytes]c                :    | j                             |           dS )zSave this presentation package to `path_or_stream`.

        `path_or_stream` can be either a path to a filesystem location (a string) or a
        file-like object.
        N)r   save)r   rN   s     r$   rQ   zPresentationPart.savej   s      	.)))))r&   c                    | j         j        D ]'}|                     |j                  |u r	|j        c S (t          d          )z1Return the slide-id associated with `slide_part`.zmatching slide_part not found)r/   r0   r2   r#   r1   
ValueError)r   r"   r3   s      r$   r+   zPresentationPart.slide_idr   sP    ]+ 	  	 E  ++z99x :8999r&   c                |    | j                                         }dt          |          dz   z  }t          |          S )zCReturn |PackURI| instance containing next available slide partname.rI   rJ   )r/   get_or_add_sldIdLstlenr	   )r   r0   partname_strs      r$   r   z%PresentationPart._next_slide_partnamey   s:     =44660CMMA4EF|$$$r&   N)r   r   )r'   r   )r+   r,   r'   r-   )r'   r   )r'   r
   )r#   r?   r'   r   )r#   r?   r'   r   )rF   rG   )rN   rO   )__name__
__module____qualname____doc__r%   propertyr)   r4   r   r7   r6   r>   rB   rE   rM   rQ   r+   r    r&   r$   r   r      s?        
	% 	% 	% 	% , , , X,    3 3 3 \3 % % % \% 1 1 \1, , , ,3 3 3 3
Q 
Q 
Q 
Q* * * *: : : % % X% % %r&   r   N)r[   
__future__r   typingr   r   r   pptx.opc.constantsr   r   pptx.opc.packager   pptx.opc.packurir	   pptx.parts.slider
   r   pptx.presentationr   	pptx.utilr   pptx.parts.corepropsr   
pptx.slider   r   r   r   r   r]   r&   r$   <module>rh      s*   : : " " " " " " . . . . . . . . . . 6 6 6 6 6 6 $ $ $ $ $ $ $ $ $ $ $ $ 7 7 7 7 7 7 7 7 * * * * * * " " " " " " H777777GGGGGGGGGGGGk% k% k% k% k%w k% k% k% k% k%r&   