§
    +Áôgô=  ã                   óÖ   — d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ  G d„ dej        ¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ d¦  «        ZdS )z
Post-processing hooks
é    N)ÚZipFile)ÚTarFileé   )Ú
get_loggerc                   ó�   — e Zd ZdZdd„Zeej        d„ ¦   «         ¦   «         Zej        d„ ¦   «         Z	ej        d„ ¦   «         Z
d„ ZdS )	ÚExtractorProcessoraà  
    Abstract base class for extractions from compressed archives.

    Subclasses can be used with :meth:`pooch.Pooch.fetch` and
    :func:`pooch.retrieve` to unzip a downloaded data file into a folder in the
    local data store. :meth:`~pooch.Pooch.fetch` will return a list with the
    names of the extracted files instead of the archive.

    Parameters
    ----------
    members : list or None
        If None, will unpack all files in the archive. Otherwise, *members*
        must be a list of file names to unpack from the archive. Only these
        files will be unpacked.
    extract_dir : str or None
        If None, files will be unpacked to the default location (a folder in
        the same location as the downloaded zip file, with a suffix added).
        Otherwise, files will be unpacked to ``extract_dir``, which is
        interpreted as a *relative path* (relative to the cache location
        provided by :func:`pooch.retrieve` or :meth:`pooch.Pooch.fetch`).

    Nc                 ó"   — || _         || _        d S ©N)ÚmembersÚextract_dir)Úselfr   r   s      úY/var/www/html/bac/bac_backend/python/env/lib/python3.11/site-packages/pooch/processors.pyÚ__init__zExtractorProcessor.__init__/   s   € ØˆŒØ&ˆÔÐÐó    c                 ó   — dS )zš
        String appended to unpacked archive folder name.
        Only used if extract_dir is None.
        MUST BE IMPLEMENTED BY CHILD CLASSES.
        N© ©r   s    r   ÚsuffixzExtractorProcessor.suffix3   ó   € € € r   c                 ó   — dS )zf
        Return all the members in the archive.
        MUST BE IMPLEMENTED BY CHILD CLASSES.
        Nr   )r   Úfnames     r   Ú_all_memberszExtractorProcessor._all_members<   r   r   c                 ó   — dS )z�
        This method receives an argument for the archive to extract and the
        destination path.
        MUST BE IMPLEMENTED BY CHILD CLASSES.
        Nr   )r   r   r   s      r   Ú_extract_filez ExtractorProcessor._extract_fileC   r   r   c           
      óî  ‡ ‡— ‰ j         €|‰ j        z   ‰ _         nV|                     t          j        j        d¬¦  «        d         }t          j                             |‰ j         ¦  «        ‰ _         ‰ j        �‰ j        s‰                      |¦  «        }n‰ j        }|dv s?t          j         	                    ‰ j         ¦  «        rt          ˆ fd„|D ¦   «         ¦  «        s6t          j        ‰ j         d¬¦  «         ‰                      |‰ j         ¦  «         g }t          j        ‰ j         ¦  «        D ]Å\  }}}	|	D ]¼}
t          j                             t          j                             t          j                             |‰ j         ¦  «        |
¦  «        ¦  «        Š‰ j        � t!          ˆfd	„‰ j        D ¦   «         ¦  «        r3|                     t          j                             ||
¦  «        ¦  «         Œ½ŒÆ|S )
a  
        Extract all files from the given archive.

        Parameters
        ----------
        fname : str
            Full path of the zipped file in local storage.
        action : str
            Indicates what action was taken by :meth:`pooch.Pooch.fetch` or
            :func:`pooch.retrieve`:

            * ``"download"``: File didn't exist locally and was downloaded
            * ``"update"``: Local file was outdated and was re-download
            * ``"fetch"``: File exists and is updated so it wasn't downloaded

        pooch : :class:`pooch.Pooch`
            The instance of :class:`pooch.Pooch` that is calling this.

        Returns
        -------
        fnames : list of str
            A list of the full path to all files in the extracted archive.

        Nr   )Úmaxsplitr   ©ÚupdateÚdownloadc              3   óœ   •K  — | ]F}t           j                             t           j                             ‰j        |¦  «        ¦  «        V — ŒGd S r
   )ÚosÚpathÚexistsÚjoinr   )Ú.0Úmr   s     €r   ú	<genexpr>z.ExtractorProcessor.__call__.<locals>.<genexpr>s   sU   øè è € ð ð ØFG•”—’�rœwŸ|š|¨DÔ,<¸aÑ@Ô@ÑAÔAðð ð ð ð ð r   T)Úexist_okc              3   ó|   •K  — | ]6}‰                      t          j                             |¦  «        ¦  «        V — Œ7d S r
   )Ú
startswithr!   r"   Únormpath)r%   r&   Úrelpaths     €r   r'   z.ExtractorProcessor.__call__.<locals>.<genexpr>ƒ   sR   øè è € ð /ð /Ø@A�G×&Ò&¥r¤w×'7Ò'7¸Ñ':Ô':Ñ;Ô;ð/ð /ð /ð /ð /ð /r   )r   r   Úrsplitr!   r"   Úsepr$   r   r   r#   ÚallÚmakedirsr   Úwalkr+   r,   ÚanyÚappend)r   r   ÚactionÚpoochÚarchive_dirr   Úfnamesr"   Ú_ÚfilesÚfilenamer,   s   `          @r   Ú__call__zExtractorProcessor.__call__K   s  øø€ ð2 ÔÐ#Ø$ t¤{Ñ2ˆDÔÐàŸ,š,¥r¤w¤{¸Q˜,Ñ?Ô?ÀÔBˆKÝ!œwŸ|š|¨K¸Ô9IÑJÔJˆDÔð Œ<Ð t¤|ÐØ×'Ò'¨Ñ.Ô.ˆGˆGà”lˆGàÐ-Ð-Ð-Ý”G—N’N 4Ô#3Ñ4Ô4ð .åð ð ð ð ØKRðñ ô ñ ô ð .õ ŒK˜Ô(°4Ð8Ñ8Ô8Ð8Ø×Ò˜u dÔ&6Ñ7Ô7Ð7ð ˆÝ œg dÔ&6Ñ7Ô7ð 	@ð 	@‰NˆD�!�UØ!ð @ð @�Ýœ'×*Ò*Ý”G—L’L¥¤§¢°°tÔ7GÑ!HÔ!HÈ(ÑSÔSñô �ð ”<Ð'­3ð /ð /ð /ð /ØEIÄ\ð/ñ /ô /ñ ,ô ,Ð'ð —M’M¥"¤'§,¢,¨t°XÑ">Ô">Ñ?Ô?Ð?øð@ð ˆr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚpropertyÚabcÚabstractmethodr   r   r   r;   r   r   r   r   r      s¨   € € € € € ðð ð.'ð 'ð 'ð 'ð ØÔðð ñ Ôñ „Xðð 	Ôðð ñ Ôðð 	Ôðð ñ Ôðð=ð =ð =ð =ð =r   r   c                   ó4   — e Zd ZdZed„ ¦   «         Zd„ Zd„ ZdS )ÚUnzipa  
    Processor that unpacks a zip archive and returns a list of all files.

    Use with :meth:`pooch.Pooch.fetch` or :func:`pooch.retrieve` to unzip a
    downloaded data file into a folder in the local data store. The
    method/function will return a list with the names of the unzipped files
    instead of the zip archive.

    The output folder is ``{fname}.unzip``.

    Parameters
    ----------
    members : list or None
        If None, will unpack all files in the zip archive. Otherwise, *members*
        must be a list of file names to unpack from the archive. Only these
        files will be unpacked.
    extract_dir : str or None
        If None, files will be unpacked to the default location (a folder in
        the same location as the downloaded zip file, with the suffix
        ``.unzip`` added). Otherwise, files will be unpacked to
        ``extract_dir``, which is interpreted as a *relative path* (relative to
        the cache location provided by :func:`pooch.retrieve` or
        :meth:`pooch.Pooch.fetch`).

    c                 ó   — dS )úl
        String appended to unpacked archive folder name.
        Only used if extract_dir is None.
        z.unzipr   r   s    r   r   zUnzip.suffix¦   ó	   € ð ˆxr   c                 ó~   — t          |d¦  «        5 }|                     ¦   «         cddd¦  «         S # 1 swxY w Y   dS )ú(Return all members from a given archive.ÚrN)r   Únamelist)r   r   Úzip_files      r   r   zUnzip._all_members®   s‚   € å�U˜CÑ Ô ð 	' HØ×$Ò$Ñ&Ô&ð	'ð 	'ð 	'ð 	'ñ 	'ô 	'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'øøøð 	'ð 	'ð 	'ð 	'ð 	'ð 	's   ‘2²6¹6c                 ó¦  ‡— t          |d¦  «        5 }| j        €:t          ¦   «                              d||¦  «         |                     |¬¦  «         ne| j        D ]]Št          ¦   «                              d‰||¦  «         ˆfd„|                     ¦   «         D ¦   «         }|                     ||¬¦  «         Œ^ddd¦  «         dS # 1 swxY w Y   dS )úo
        This method receives an argument for the archive to extract and the
        destination path.
        rJ   Nz"Unzipping contents of '%s' to '%s'©r"   ú!Extracting '%s' from '%s' to '%s'c                 ó²   •— g | ]S}t           j                             |¦  «                             t           j                             ‰¦  «        ¦  «        ¯Q|‘ŒTS r   )r!   r"   r+   r*   )r%   ÚnameÚmembers     €r   ú
<listcomp>z'Unzip._extract_file.<locals>.<listcomp>Ê   s]   ø€ ð &ð &ð &à Ýœ7×+Ò+¨DÑ1Ô1×<Ò<½R¼W×=MÒ=MÈfÑ=UÔ=UÑVÔVð&Øð&ð &ð &r   ©r   r"   )r   r   r   ÚinfoÚ
extractallrK   )r   r   r   rL   Úsubdir_membersrS   s        @r   r   zUnzip._extract_file³   sZ  ø€ õ
 �U˜CÑ Ô ð 	R HØŒ|Ð#Ý‘”×!Ò!Ø8¸%Àñô ð ð ×#Ò#¨Ð#Ñ5Ô5Ð5Ð5à"œlð Rð R�FÝ‘L”L×%Ò%Ø;¸VÀUÈKñô ð ð&ð &ð &ð &à$,×$5Ò$5Ñ$7Ô$7ð&ñ &ô &�Nð ×'Ò'°À[Ð'ÑQÔQÐQÐQð1	Rð 	Rð 	Rñ 	Rô 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Røøøð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rs   ’B'CÃC
ÃC
N©r<   r=   r>   r?   r@   r   r   r   r   r   r   rD   rD   ‹   s\   € € € € € ðð ð4 ðð ñ „Xðð'ð 'ð 'ð
Rð Rð Rð Rð Rr   rD   c                   ó4   — e Zd ZdZed„ ¦   «         Zd„ Zd„ ZdS )ÚUntara  
    Processor that unpacks a tar archive and returns a list of all files.

    Use with :meth:`pooch.Pooch.fetch` or :func:`pooch.retrieve` to untar a
    downloaded data file into a folder in the local data store. The
    method/function will return a list with the names of the extracted files
    instead of the archive.

    The output folder is ``{fname}.untar``.


    Parameters
    ----------
    members : list or None
        If None, will unpack all files in the archive. Otherwise, *members*
        must be a list of file names to unpack from the archive. Only these
        files will be unpacked.
    extract_dir : str or None
        If None, files will be unpacked to the default location (a folder in
        the same location as the downloaded tar file, with the suffix
        ``.untar`` added). Otherwise, files will be unpacked to
        ``extract_dir``, which is interpreted as a *relative path* (relative to
        the cache location  provided by :func:`pooch.retrieve` or
        :meth:`pooch.Pooch.fetch`).
    c                 ó   — dS )rF   z.untarr   r   s    r   r   zUntar.suffixî   rG   r   c                 óœ   — t          j        |d¦  «        5 }d„ |                     ¦   «         D ¦   «         cddd¦  «         S # 1 swxY w Y   dS )rI   rJ   c                 ó   — g | ]	}|j         ‘Œ
S r   )rR   )r%   rV   s     r   rT   z&Untar._all_members.<locals>.<listcomp>ù   s   € Ð@Ð@Ð@ $�D”IÐ@Ð@Ð@r   N)r   ÚopenÚ
getmembers)r   r   Útar_files      r   r   zUntar._all_membersö   s¥   € åŒ\˜% Ñ%Ô%ð 	A¨Ø@Ð@¨(×*=Ò*=Ñ*?Ô*?Ð@Ñ@Ô@ð	Að 	Að 	Að 	Añ 	Aô 	Að 	Að 	Að 	Að 	Að 	Að 	Aøøøð 	Að 	Að 	Að 	Að 	Að 	As   –AÁAÁAc                 ó°  ‡— t          j        |d¦  «        5 }| j        €:t          ¦   «                              d||¦  «         |                     |¬¦  «         ne| j        D ]]Št          ¦   «                              d‰||¦  «         ˆfd„|                     ¦   «         D ¦   «         }|                     ||¬¦  «         Œ^ddd¦  «         dS # 1 swxY w Y   dS )rN   rJ   Nz"Untarring contents of '%s' to '%s'rO   rP   c                 ó¼   •— g | ]X}t           j                             |j        ¦  «                             t           j                             ‰¦  «        ¦  «        ¯V|‘ŒYS r   )r!   r"   r+   rR   r*   )r%   rV   rS   s     €r   rT   z'Untar._extract_file.<locals>.<listcomp>  sd   ø€ ð &ð &ð &à Ýœ7×+Ò+¨D¬IÑ6Ô6×AÒAÝœG×,Ò,¨VÑ4Ô4ñô ð&Øð&ð &ð &r   rU   )r   r_   r   r   rV   rW   r`   )r   r   r   ra   rX   rS   s        @r   r   zUntar._extract_fileû   s\  ø€ õ
 Œ\˜% Ñ%Ô%ð 	R¨ØŒ|Ð#Ý‘”×!Ò!Ø8¸%Àñô ð ð ×#Ò#¨Ð#Ñ5Ô5Ð5Ð5à"œlð Rð R�FÝ‘L”L×%Ò%Ø;¸VÀUÈKñô ð ð&ð &ð &ð &à$,×$7Ò$7Ñ$9Ô$9ð&ñ &ô &�Nð ×'Ò'°À[Ð'ÑQÔQÐQÐQð9	Rð 	Rð 	Rñ 	Rô 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Røøøð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rs   —B'CÃCÃCNrY   r   r   r   r[   r[   Ó   s_   € € € € € ðð ð4 ðð ñ „XððAð Að Að
!Rð !Rð !Rð !Rð !Rr   r[   c                   óB   — e Zd ZdZdeeeedœZddddœZdd	„Z	d
„ Z
d„ ZdS )Ú
Decompressa3  
    Processor that decompress a file and returns the decompressed version.

    Use with :meth:`pooch.Pooch.fetch` or :func:`pooch.retrieve` to decompress
    a downloaded data file so that it can be easily opened. Useful for data
    files that take a long time to decompress (exchanging disk space for
    speed).

    Supported decompression methods are LZMA (``.xz``), bzip2 (``.bz2``), and
    gzip (``.gz``).

    File names with the standard extensions (see above) can use
    ``method="auto"`` to automatically determine the compression method. This
    can be overwritten by setting the *method* argument.

    .. note::

        To unpack zip and tar archives with one or more files, use
        :class:`pooch.Unzip` and :class:`pooch.Untar` instead.

    The output file is ``{fname}.decomp`` by default but it can be changed by
    setting the ``name`` parameter.

    .. warning::

        Passing in ``name`` can cause existing data to be lost! For example, if
        a file already exists with the specified name it will be overwritten
        with the new decompressed file content. **Use this option with
        caution.**

    Parameters
    ----------
    method : str
        Name of the compression method. Can be "auto", "lzma", "xz", "bzip2",
        or "gzip".
    name : None or str
        Defines the decompressed file name. The file name will be
        ``{fname}.decomp`` if ``None`` (default) or the given name otherwise.
        Note that the name should **not** include the full (or relative) path,
        it should be just the file name itself.

    N)ÚautoÚlzmaÚxzÚgzipÚbzip2rg   ri   rj   )z.xzz.gzz.bz2rf   c                 ó"   — || _         || _        d S r
   )ÚmethodrR   )r   rl   rR   s      r   r   zDecompress.__init__N  s   € ØˆŒØˆŒ	ˆ	ˆ	r   c                 ó:  — | j         €|dz   }nBt          j                             t          j                             |¦  «        | j         ¦  «        }|dv st          j                             |¦  «        s¨t          ¦   «                              d||| j        ¦  «         |  	                    |¦  «        }t          |d¦  «        5 }| 
                    |¦  «        5 }t          j        ||¦  «         ddd¦  «         n# 1 swxY w Y   ddd¦  «         n# 1 swxY w Y   |S )aK  
        Decompress the given file.

        The output file will be either ``{fname}.decomp`` or the given *name*
        class attribute.

        Parameters
        ----------
        fname : str
            Full path of the compressed file in local storage.
        action : str
            Indicates what action was taken by :meth:`pooch.Pooch.fetch` or
            :func:`pooch.retrieve`:

            - ``"download"``: File didn't exist locally and was downloaded
            - ``"update"``: Local file was outdated and was re-download
            - ``"fetch"``: File exists and is updated so it wasn't downloaded

        pooch : :class:`pooch.Pooch`
            The instance of :class:`pooch.Pooch` that is calling this.

        Returns
        -------
        fname : str
            The full path to the decompressed file.
        Nz.decompr   z-Decompressing '%s' to '%s' using method '%s'.zw+b)rR   r!   r"   r$   Údirnamer#   r   rV   rl   Ú_compression_moduler_   ÚshutilÚcopyfileobj)r   r   r4   r5   ÚdecompressedÚmoduleÚoutputÚ
compresseds           r   r;   zDecompress.__call__R  s|  € ð6 Œ9ÐØ  9Ñ,ˆLˆLåœ7Ÿ<š<­¬¯ª¸Ñ(>Ô(>ÀÄ	ÑJÔJˆLØÐ+Ð+Ð+µ2´7·>²>À,Ñ3OÔ3OÐ+Ý‰LŒL×ÒØ?ØØØ”ñ	ô ð ð ×-Ò-¨eÑ4Ô4ˆFÝ�l EÑ*Ô*ð ;¨fØ—[’[ Ñ'Ô'ð ;¨:ÝÔ& z°6Ñ:Ô:Ð:ð;ð ;ð ;ñ ;ô ;ð ;ð ;ð ;ð ;ð ;ð ;øøøð ;ð ;ð ;ð ;ð;ð ;ð ;ñ ;ô ;ð ;ð ;ð ;ð ;ð ;ð ;øøøð ;ð ;ð ;ð ;ð Ðs6   ÃDÃC9Ã-DÃ9C=	Ã=DÄ C=	ÄDÄDÄDc                 óX  — d}| j         | j        vrad| j         › dt          | j                             ¦   «         ¦  «        › d�}| j         dv rd                     ||g¦  «        }t          |¦  «        ‚| j         dk    r�t          j                             |¦  «        d         }|| j	        vrWd	|› dt          | j	                             ¦   «         ¦  «        › d�}|d
v rd                     ||g¦  «        }t          |¦  «        ‚| j        | j	        |                  S | j        | j                  S )a  
        Get the Python module compatible with fname and the chosen method.

        If the *method* attribute is "auto", will select a method based on the
        extension. If no recognized extension is in the file name, will raise a
        ValueError.
        z:To unpack zip/tar archives, use pooch.Unzip/Untar instead.zInvalid compression method 'z'. Must be one of 'z'.>   ÚtarÚzipú rf   éÿÿÿÿzUnrecognized file extension '>   ú.tarú.zip)
rl   ÚmodulesÚlistÚkeysr$   Ú
ValueErrorr!   r"   ÚsplitextÚ
extensions)r   r   Úerror_archivesÚmessageÚexts        r   ro   zDecompress._compression_module~  s_  € ð VˆØŒ;˜dœlÐ*Ð*ðA¨t¬{ð Að AÝ#'¨¬×(9Ò(9Ñ(;Ô(;Ñ#<Ô#<ðAð Að Að ð Œ{˜nÐ,Ð,ØŸ(š( G¨^Ð#<Ñ=Ô=�Ý˜WÑ%Ô%Ð%ØŒ;˜&Ò Ð Ý”'×"Ò" 5Ñ)Ô)¨"Ô-ˆCØ˜$œ/Ð)Ð)ðH°Cð Hð HÝ'+¨D¬O×,@Ò,@Ñ,BÔ,BÑ'CÔ'CðHð Hð Hð ð Ð*Ð*Ð*Ø!Ÿhšh¨°Ð'@ÑAÔA�GÝ  Ñ)Ô)Ð)Ø”< ¤°Ô 4Ô5Ð5ØŒ|˜DœKÔ(Ð(r   )rf   N)r<   r=   r>   r?   rg   ri   Úbz2r}   r‚   r   r;   ro   r   r   r   re   re     sv   € € € € € ð)ð )ðV  T°¸tÈcÐRÐR€GØ¨¸Ð@Ð@€Jðð ð ð ð*ð *ð *ðX)ð )ð )ð )ð )r   re   )r?   rA   r!   r†   ri   rg   rp   Úzipfiler   Útarfiler   Úutilsr   ÚABCr   rD   r[   re   r   r   r   ú<module>r‹      sf  ððð ð €
€
€
Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ðqð qð qð qð q˜œñ qô qð qðhERð ERð ERð ERð ERÐñ ERô ERð ERðPIRð IRð IRð IRð IRÐñ IRô IRð IRðX{)ð {)ð {)ð {)ð {)ñ {)ô {)ð {)ð {)ð {)r   