
    ,h                         d Z ddl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  G d	 d
e      Z G d de      Z G d de      Zy)zOverall .pptx package.    )RELATIONSHIP_TYPE)
OpcPackagePackURI)CorePropertiesPart)Image	ImagePart)	MediaPart)lazypropertyc                   h    e Zd ZdZed        Zd Zd Zd Zd Z	e
d        Zed        Zed	        Zy
)PackagezAn overall .pptx package.c                     	 | j                  t        j                        S # t        $ r: t	        j
                  |       }| j                  |t        j                         |cY S w xY w)zInstance of |CoreProperties| holding read/write Dublin Core doc properties.

        Creates a default core properties part if one is not present (not common).
        )part_related_byRTCORE_PROPERTIESKeyErrorr   default	relate_to)self
core_propss     N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/package.pycore_propertieszPackage.core_properties   sW    	''(:(:;; 	+33D9JNN:r'9'9:	s   ! A A$#A$c                 8    | j                   j                  |      S )z
        Return an |ImagePart| object containing the image in *image_file*. If
        the image part already exists in this package, it is reused,
        otherwise a new one is created.
        )_image_partsget_or_add_image_part)r   
image_files     r   r   zPackage.get_or_add_image_part   s       66zBB    c                 8    | j                   j                  |      S )zReturn a |MediaPart| object containing the media in *media*.

        If a media part for this media bytestream ("file") is already present
        in this package, it is reused, otherwise a new one is created.
        )_media_partsget_or_add_media_part)r   medias     r   r    zPackage.get_or_add_media_part&   s       66u==r   c                 <      fd} |       }t        d||fz        S )z
        Return a |PackURI| instance representing the next available image
        partname, by sequence number. *ext* is used as the extention on the
        returned partname.
        c                  D   t        j                         D  cg c]I  } | j                  j                  d      r,| j                  j                  | j                  j                  K c}       }t        |      D ]  \  }}|dz   }||k  s|c S  t        |      dz   S c c} w )Nz/ppt/media/image   sorted
iter_partspartname
startswithidx	enumeratelen)part
image_idxsi	image_idxr*   r   s        r   first_available_image_idxz>Package.next_image_partname.<locals>.first_available_image_idx5   s     !% 1001CD MM--9	 MM%%	J !** 5 9!e?J z?Q&&s   ABz/ppt/media/image%d.%sr   )r   extr1   r*   s   `   r   next_image_partnamezPackage.next_image_partname.   s'    	'" ().#s;<<r   c                 <      fd} |       }t        d||fz        S )zReturn |PackURI| instance for next available media partname.

        Partname is first available, starting at sequence number 1. Empty
        sequence numbers are reused. *ext* is used as the extension on the
        returned partname.
        c                     t        j                         D  cg c]3  } | j                  j                  d      r| j                  j                  5 c}       }t        |      D ]  \  }}|dz   }||k  s|c S  t        |      dz   S c c} w )Nz/ppt/media/mediar$   r%   )r-   
media_idxsr/   	media_idxr*   r   s        r   first_available_media_idxz>Package.next_media_partname.<locals>.first_available_media_idxQ   s     !% 1}}//0BC MM%%J !** 5 9!e?J z?Q&&s   8Bz/ppt/media/media%d.%sr   )r   r2   r8   r*   s   `   r   next_media_partnamezPackage.next_media_partnameI   s'    	' ().#s;<<r   c                     | j                   S )zU
        Reference to the |Presentation| instance contained in this package.
        )main_document_partr   s    r   presentation_partzPackage.presentation_partb   s    
 &&&r   c                     t        |       S )zc
        |_ImageParts| object providing access to the image parts in this
        package.
        )_ImagePartsr<   s    r   r   zPackage._image_partsi   s     4  r   c                     t        |       S )zReturn |_MediaParts| object for this package.

        The media parts object provides access to all the media parts in this
        package.
        )_MediaPartsr<   s    r   r   zPackage._media_partsq   s     4  r   N)__name__
__module____qualname____doc__r   r   r   r    r3   r9   propertyr=   r   r    r   r   r   r      sh    #
 
C>=6=2 ' ' ! ! ! !r   r   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )r?   z0Provides access to the image parts in a package.c                 8    t         t        |           || _        y N)superr?   __init___packager   package	__class__s     r   rL   z_ImageParts.__init__~       k4)+r   c              #      K   g }| j                   j                         D ]S  }|j                  r|j                  t        j
                  k7  r.|j                  }||v r?|j                  |       | U yw)zQ
        Generate a reference to each |ImagePart| object in the package.
        N)rM   	iter_relsis_externalreltyper   IMAGEtarget_partappend)r   image_partsrel
image_parts       r   __iter__z_ImageParts.__iter__   sn      ==**, 		C{{bhh&J[(z*		s   A4A6c                     t        j                  |      }| j                  |j                        }| t	        j
                  | j                  |      S |S )a=  Return |ImagePart| object containing the image in `image_file`.

        `image_file` can be either a path to an image file or a file-like object
        containing an image. If an image part containing this same image already exists,
        that instance is returned, otherwise a new image part is created.
        )r   	from_file_find_by_sha1sha1r	   newrM   )r   r   imager[   s       r   r   z!_ImageParts.get_or_add_image_part   sE     
+''

3
6@6Hy}}T]]E2XjXr   c                 R    | D ]"  }t        |d      s|j                  |k(  s |c S  y)z
        Return an |ImagePart| object belonging to this package or |None| if
        no matching image part is found. The image part is identified by the
        SHA1 hash digest of the image binary it contains.
        r`   N)hasattrr`   )r   r`   r[   s      r   r_   z_ImageParts._find_by_sha1   s7      	"J:v.$&!!	" r   )	rB   rC   rD   rE   rL   r\   r   r_   __classcell__rP   s   @r   r?   r?   {   s    :  	Yr   r?   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )rA   zProvides access to the media parts in a package.

    Supports iteration and :meth:`get()` using the media object SHA1 hash as
    its key.
    c                 8    t         t        |           || _        y rJ   )rK   rA   rL   rM   rN   s     r   rL   z_MediaParts.__init__   rQ   r   c              #     K   g }| j                   j                         D ]b  }|j                  r|j                  t        j
                  t        j                  fvr=|j                  }||v rN|j                  |       | d yw)z?Generate a reference to each |MediaPart| object in the package.N)	rM   rS   rT   rU   r   MEDIAVIDEOrW   rX   )r   media_partsrZ   
media_parts       r   r\   z_MediaParts.__iter__   sw     
 ==**, 		C{{288RXX"66J[(z*		s   BBc                     | j                  |j                        }| t        j                  | j                  |      }|S )zReturn a |MediaPart| object containing the media in *media*.

        If this package already contains a media part for the same
        bytestream, that instance is returned, otherwise a new media part is
        created.
        )r_   r`   r
   ra   rM   )r   r!   rm   s      r   r    z!_MediaParts.get_or_add_media_part   s8     ''

3
"t}}e<Jr   c                 8    | D ]  }|j                   |k(  s|c S  y)zReturn |MediaPart| object having *sha1* hash or None if not found.

        All media parts belonging to this package are considered. A media
        part is identified by the SHA1 hash digest of its bytestream
        ("file").
        N)r`   )r   r`   rm   s      r   r_   z_MediaParts._find_by_sha1   s*      	"J$&!!	" r   )	rB   rC   rD   rE   rL   r\   r    r_   re   rf   s   @r   rA   rA      s     "

r   rA   N)rE   pptx.opc.constantsr   r   pptx.opc.packager   pptx.opc.packurir   pptx.parts.corepropsr   pptx.parts.imager   r	   pptx.parts.mediar
   	pptx.utilr   r   objectr?   rA   rG   r   r   <module>rx      sG     6 ' $ 3 - & "j!j j!Z.& .b2& 2r   