Ë
    \Rði¥  ã                   ó¦   — d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	  G d„ d«      Z
 G d„ d	«      Z G d
„ de
«      Z G d„ de
«      Z G d„ de«      Zy)zMProvides a general interface to a `physical` OPC package, such as a zip file.é    N)ÚZIP_DEFLATEDÚZipFileÚ
is_zipfile)ÚPackageNotFoundError)ÚCONTENT_TYPES_URIc                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚPhysPkgReaderz,Factory for physical package reader objects.c                 óâ   •— t        |t        «      rFt        j                  j	                  |«      rt
        }n&t        |«      rt        }nt        d|z  «      ‚t        }t        t        | �/  |«      S )NzPackage not found at '%s')Ú
isinstanceÚstrÚosÚpathÚisdirÚ_DirPkgReaderr   Ú_ZipPkgReaderr   Úsuperr	   Ú__new__)ÚclsÚpkg_fileÚ
reader_clsÚ	__class__s      €úL/var/www/html/Extract/venv/lib/python3.12/site-packages/docx/opc/phys_pkg.pyr   zPhysPkgReader.__new__   sW   ø€ ä�h¤Ô$Ü�w‰w�}‰}˜XÔ&Ü*‘
Ü˜HÔ%Ü*‘
ä*Ð+FÈÑ+QÓRÐRä&ˆJä”] CÑ0°Ó<Ð<ó    ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__©r   s   @r   r	   r	   
   s   ø„ Ù6÷=ð =r   r	   c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚPhysPkgWriterz,Factory for physical package writer objects.c                 ó2   •— t         t        | �  t        «      S )N)r   r"   r   Ú_ZipPkgWriter)r   r   r   s     €r   r   zPhysPkgWriter.__new__   s   ø€ Ü”] CÑ0´Ó?Ð?r   r   r    s   @r   r"   r"      s   ø„ Ù6÷@ð @r   r"   c                   óD   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zed„ «       Zd„ Z	ˆ xZ
S )r   zWImplements |PhysPkgReader| interface for an OPC package extracted into a
    directory.c                 ór   •— t         t        | �  «        t        j                  j                  |«      | _        y)zA`path` is the path to a directory containing an expanded package.N)r   r   Ú__init__r   r   ÚabspathÚ_path)Úselfr   r   s     €r   r'   z_DirPkgReader.__init__'   s$   ø€ äŒm˜TÑ+Ô-Ü—W‘W—_‘_ TÓ*ˆ�
r   c                 óÒ   — t         j                  j                  | j                  |j                  «      }t        |d«      5 }|j                  «       }ddd«       |S # 1 sw Y   S xY w)zIReturn contents of file corresponding to `pack_uri` in package directory.ÚrbN)r   r   Újoinr)   Ú
membernameÚopenÚread)r*   Úpack_urir   ÚfÚblobs        r   Úblob_forz_DirPkgReader.blob_for,   sQ   € ä�w‰w�|‰|˜DŸJ™J¨×(;Ñ(;Ó<ˆÜ�$˜Óð 	 Ø—6‘6“8ˆD÷	àˆ÷	àˆús   ÁAÁA&c                  ó   — y)z|Provides interface consistency with |ZipFileSystem|, but does nothing, a
        directory file system doesn't need closing.N© ©r*   s    r   Úclosez_DirPkgReader.close3   s   € ð 	r   c                 ó,   — | j                  t        «      S )z7Return the `[Content_Types].xml` blob from the package.©r4   r   r7   s    r   Úcontent_types_xmlz_DirPkgReader.content_types_xml8   ó   € ð �}‰}Ô.Ó/Ð/r   c                 ób   — 	 | j                  |j                  «      }|S # t        $ r d}Y |S w xY w)z`Return rels item XML for source with `source_uri`, or None if the item has no
        rels item.N)r4   Úrels_uriÚIOError©r*   Ú
source_uriÚrels_xmls      r   Úrels_xml_forz_DirPkgReader.rels_xml_for=   s=   € ð	Ø—}‘} Z×%8Ñ%8Ó9ˆHð ˆøô ò 	Ø‰HØˆð	úó   ‚ Ÿ.­.©r   r   r   r   r'   r4   r8   Úpropertyr;   rC   r   r    s   @r   r   r   #   s0   ø„ ñô+ò
òð
 ñ0ó ð0ör   r   c                   óD   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zed„ «       Zd„ Z	ˆ xZ
S )r   z@Implements |PhysPkgReader| interface for a zip file OPC package.c                 óL   •— t         t        | �  «        t        |d«      | _        y )NÚr)r   r   r'   r   Ú_zipf©r*   r   r   s     €r   r'   z_ZipPkgReader.__init__J   s   ø€ ÜŒm˜TÑ+Ô-Ü˜X sÓ+ˆ�
r   c                 óL   — | j                   j                  |j                  «      S )zReturn blob corresponding to `pack_uri`.

        Raises |ValueError| if no matching member is present in zip archive.
        )rJ   r0   r.   )r*   r1   s     r   r4   z_ZipPkgReader.blob_forN   s   € ð
 �z‰z�‰˜x×2Ñ2Ó3Ð3r   c                 ó8   — | j                   j                  «        y)z;Close the zip archive, releasing any resources it is using.N©rJ   r8   r7   s    r   r8   z_ZipPkgReader.closeU   s   € à�
‰
×ÑÕr   c                 ó,   — | j                  t        «      S )z;Return the `[Content_Types].xml` blob from the zip package.r:   r7   s    r   r;   z_ZipPkgReader.content_types_xmlY   r<   r   c                 ób   — 	 | j                  |j                  «      }|S # t        $ r d}Y |S w xY w)z]Return rels item XML for source with `source_uri` or None if no rels item is
        present.N)r4   r>   ÚKeyErrorr@   s      r   rC   z_ZipPkgReader.rels_xml_for^   s=   € ð	Ø—}‘} Z×%8Ñ%8Ó9ˆHð ˆøô ò 	Ø‰HØˆð	úrD   rE   r    s   @r   r   r   G   s.   ø„ ÙJô,ò4òð ñ0ó ð0ör   r   c                   ó.   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zˆ xZS )r$   z@Implements |PhysPkgWriter| interface for a zip file OPC package.c                 óX   •— t         t        | �  «        t        |dt        ¬«      | _        y )NÚw)Úcompression)r   r$   r'   r   r   rJ   rK   s     €r   r'   z_ZipPkgWriter.__init__k   s    ø€ ÜŒm˜TÑ+Ô-Ü˜X s¼ÔEˆ�
r   c                 ó8   — | j                   j                  «        y)zkClose the zip archive, flushing any pending physical writes and releasing any
        resources it's using.NrN   r7   s    r   r8   z_ZipPkgWriter.closeo   s   € ð 	�
‰
×ÑÕr   c                 óP   — | j                   j                  |j                  |«       y)zYWrite `blob` to this zip package with the membername corresponding to
        `pack_uri`.N)rJ   Úwritestrr.   )r*   r1   r3   s      r   Úwritez_ZipPkgWriter.writet   s   € ð 	�
‰
×Ñ˜H×/Ñ/°Õ6r   )r   r   r   r   r'   r8   rY   r   r    s   @r   r$   r$   h   s   ø„ ÙJôFòö
7r   r$   )r   r   Úzipfiler   r   r   Údocx.opc.exceptionsr   Údocx.opc.packurir   r	   r"   r   r   r$   r6   r   r   ú<module>r]      sS   ðÙ Sã 	ß 5Ñ 5å 4Ý .÷=ñ =÷$@ñ @ô!�Mô !ôH�Mô ôB7�Mõ 7r   