ó
    Æ“,jž>  ã                   óÎ   • S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSKJr   " S S\R                  5      r " S	 S
\5      r " S S\5      r " S S5      rg)z
Post-processing hooks
é    N)ÚZipFile)ÚTarFileé   )Ú
get_loggerc                   óž   • \ rS rSrSrS
S jr\\R                  S 5       5       r	\R                  S 5       r
\R                  S 5       rS rS	rg)ÚExtractorProcessoré   a˜  
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                 ó   • Xl         X l        g ©N)ÚmembersÚextract_dir)Úselfr   r   s      ÚžC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\pooch/processors.pyÚ__init__ÚExtractorProcessor.__init__1   s   € ØŒØ&Õó    c                 ó   • g)zz
String appended to unpacked archive folder name.
Only used if extract_dir is None.
MUST BE IMPLEMENTED BY CHILD CLASSES.
N© ©r   s    r   ÚsuffixÚExtractorProcessor.suffix5   ó   � r   c                 ó   • g)zN
Return all the members in the archive.
MUST BE IMPLEMENTED BY CHILD CLASSES.
Nr   )r   Úfnames     r   Ú_all_membersÚExtractorProcessor._all_members>   r   r   c                 ó   • g)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_fileÚ ExtractorProcessor._extract_fileE   r   r   c           
      ó‚  ^ ^• T R                   c  UT R                  -   T l         OZUR                  [        R                  R
                  SS9S   n[        R                  R                  UT R                   5      T l         T R                  b  T R                  (       d  T R                  U5      nOT R                  nUS;   dH  [        R                  R                  T R                   5      (       a  [        U 4S jU 5       5      (       d;  [        R                  " T R                   SS9  T R                  UT R                   5        / n[        R                  " T R                   5       HÕ  u  pxn	U	 HÉ  n
[        R                  R                  [        R                  R                  [        R                  R                  UT R                   5      U
5      5      mT R                  b&  [!        U4S jT R                   5       5      (       d  M›  UR#                  [        R                  R                  Xz5      5        MË     M×     U$ )	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.

r   )Úmaxsplitr   ©ÚupdateÚdownloadc              3   ó²   >#   • U  HL  n[         R                  R                  [         R                  R                  TR                  U5      5      v •  MN     g 7fr   )ÚosÚpathÚexistsÚjoinr   )Ú.0Úmr   s     €r   Ú	<genexpr>Ú.ExtractorProcessor.__call__.<locals>.<genexpr>u   s9   øé € ð ÚKRÀa”—‘—‘œrŸw™wŸ|™|¨D×,<Ñ,<¸aÓ@×AÐAÊ7ùs   ƒAAT)Úexist_okc              3   ó€   >#   • U  H3  nTR                  [        R                  R                  U5      5      v •  M5     g 7fr   )Ú
startswithr&   r'   Únormpath)r*   r+   Úrelpaths     €r   r,   r-   …   s1   øé € ð /ÚEQÀ�G×&Ñ&¤r§w¡w×'7Ñ'7¸Ó':×;Ð;Â\ùs   ƒ;>)r   r   Úrsplitr&   r'   Úsepr)   r   r   r(   ÚallÚmakedirsr   Úwalkr1   r2   ÚanyÚappend)r   r   ÚactionÚpoochÚarchive_dirr   Úfnamesr'   Ú_ÚfilesÚfilenamer2   s   `          @r   Ú__call__ÚExtractorProcessor.__call__M   s¥  ù€ ð2 ×ÑÑ#Ø$ t§{¡{Ñ2ˆDÕàŸ,™,¤r§w¡w§{¡{¸Q˜,Ð?ÀÑBˆKÜ!Ÿw™wŸ|™|¨K¸×9IÑ9IÓJˆDÔð �<‰<Ñ t§|§|Ø×'Ñ'¨Ó.‰Gà—l‘lˆGàÐ-Ó-Ü—G‘G—N‘N 4×#3Ñ#3×4Ñ4Üô ÙKRó÷ ñ ô
 �KŠK˜×(Ñ(°4Ò8Ø×Ñ˜u d×&6Ñ&6Ô7ð ˆÜ Ÿgšg d×&6Ñ&6Ö7‰NˆD�UÛ!�ÜŸ'™'×*Ñ*Ü—G‘G—L‘L¤§¡§¡°°t×7GÑ7GÓ!HÈ(ÓSó�ð —<‘<Ñ'¬3ô /ØEIÇ\Â\ó/÷ ,ó ,ð —M‘M¤"§'¡'§,¡,¨tÓ">Ö?ó "ñ 8ð ˆr   )r   r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚpropertyÚabcÚabstractmethodr   r   r   rA   Ú__static_attributes__r   r   r   r   r      sg   † ñô.'ð Ø×Ññó ó ðð 	×Ññó ðð 	×Ññó ðõ=r   r   c                   ó4   • \ rS rSrSr\S 5       rS rS rSr	g)ÚUnzipé�   aÆ  
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                 ó   • g)úT
String appended to unpacked archive folder name.
Only used if extract_dir is None.
z.unzipr   r   s    r   r   ÚUnzip.suffix¨   ó   € ð r   c                 óp   • [        US5       nUR                  5       sSSS5        $ ! , (       d  f       g= f©z(Return all members from a given archive.ÚrN)r   Únamelist)r   r   Úzip_files      r   r   ÚUnzip._all_members°   s&   € ä�U˜CÔ  HØ×$Ñ$Ó&÷ !× × ús   �'§
5c           
      ó&  • [        US5       nU R                  c*  [        5       R                  SX5        UR	                  US9  O¯U R                   HŸ  n[        5       R                  SXAU5        UR                  5        Vs/ s HW  n[        R                  R                  U5      R                  [        R                  R                  U5      5      (       d  MU  UPMY     nnUR	                  XbS9  M¡     SSS5        gs  snf ! , (       d  f       g= f)úW
This method receives an argument for the archive to extract and the
destination path.
rU   Nz"Unzipping contents of '%s' to '%s')r'   ú!Extracting '%s' from '%s' to '%s'©r   r'   )
r   r   r   ÚinfoÚ
extractallrV   r&   r'   r1   r0   )r   r   r   rW   ÚmemberÚnameÚsubdir_memberss          r   r   ÚUnzip._extract_fileµ   sç   € ô
 �U˜CÔ  HØ�|‰|Ñ#Ü“×!Ñ!Ø8¸%ôð ×#Ñ#¨Ð#Ò5à"Ÿlœl�FÜ“L×%Ñ%Ø;¸VÈKôð %-×$5Ñ$5Ô$7ó&â$7˜DÜŸ7™7×+Ñ+¨DÓ1×<Ñ<¼R¿W¹W×=MÑ=MÈfÓ=U×V÷ Ù$7ð #ð &ð ×'Ñ'°Ð'ÓQñ! +÷ !Ð ùò$&÷% !Õ ús%   �A4DÂAC=ÃC=ÃDÃ=DÄ
Dr   N©
rC   rD   rE   rF   rG   rH   r   r   r   rK   r   r   r   rM   rM   �   s&   † ñð4 ñó ðò'õ
Rr   rM   c                   ó4   • \ rS rSrSr\S 5       rS rS rSr	g)ÚUntaréÕ   aÀ  
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                 ó   • g)rP   z.untarr   r   s    r   r   ÚUntar.suffixð   rR   r   c                 óÄ   • [         R                  " US5       nUR                  5        Vs/ s H  o3R                  PM     snsSSS5        $ s  snf ! , (       d  f       g= frT   )r   ÚopenÚ
getmembersr`   )r   r   Útar_filer]   s       r   r   ÚUntar._all_membersø   sE   € ä�\Š\˜% Ô%¨Ø*2×*=Ñ*=Ô*?Ó@Ò*? $—I”IÑ*?Ñ@÷ &Ñ%ùÚ@÷ &Õ%ús   ˜A«AÁ AÁAÁ
Ac           
      ó˜  • [         R                  S:  a  0 OSS0n[        R                  " US5       nU R                  c/  [        5       R                  SX5        UR                  " S
SU0UD6  O¾U R                   H®  n[        5       R                  SXQU5        UR                  5        Vs/ s Ha  n[        R                  R                  UR                  5      R                  [        R                  R                  U5      5      (       d  M_  UPMc     nnUR                  " S
XrS	.UD6  M°     SSS5        gs  snf ! , (       d  f       g= f)rZ   )é   é   ÚfilterÚdatarU   Nz"Untarring contents of '%s' to '%s'r'   r[   r\   r   )ÚsysÚversion_infor   rj   r   r   r]   r^   rk   r&   r'   r1   r`   r0   )r   r   r   Úfilter_kwargrl   r_   r]   ra   s           r   r   ÚUntar._extract_fileý   s  € ô
 !×-Ñ-°Ó7‘r¸hÈÐ=OˆÜ�\Š\˜% Ô%¨Ø�|‰|Ñ#Ü“×!Ñ!Ø8¸%ôð ×#Ò#ÑE¨ÐE¸ÓEà"Ÿlœl�FÜ“L×%Ñ%Ø;¸VÈKôð %-×$7Ñ$7Ô$9ó&â$9˜DÜŸ7™7×+Ñ+¨D¯I©IÓ6×AÑAÜŸG™G×,Ñ,¨VÓ4÷÷ Ù$9ð #ð &ð ×'Ò'ð Ø .ñØDPôñ) +÷ &Ð%ùò(&÷) &Õ%ús%   ²A9D;Â+AD6ÄD6ÄD;Ä6D;Ä;
E	r   Nrc   r   r   r   re   re   Õ   s&   † ñð4 ñó ðòAõ
$r   re   c                   óJ   • \ rS rSrSrS\\\\S.rSSSS.r	SS	 jr
S
 rS rSrg)Ú
Decompressi$  a·  
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Úbzip2rz   r|   r}   )z.xzz.gzz.bz2c                 ó   • Xl         X l        g r   ©Úmethodr`   )r   r€   r`   s      r   r   ÚDecompress.__init__S  s   € ØŒØ�	r   c                 óP  • U R                   c  US-   nOG[        R                  R                  [        R                  R	                  U5      U R                   5      nUS;   d$  [        R                  R                  U5      (       d~  [        5       R                  SUUU R                  5        U R                  U5      n[        US5       nUR                  U5       n[        R                  " Xv5        SSS5        SSS5        U$ U$ ! , (       d  f       N= f! , (       d  f       U$ = f)a«  
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)r`   r&   r'   r)   Údirnamer(   r   r]   r€   Ú_compression_modulerj   ÚshutilÚcopyfileobj)r   r   r:   r;   ÚdecompressedÚmoduleÚoutputÚ
compresseds           r   rA   ÚDecompress.__call__W  sã   € ð6 �9‰9ÑØ  9Ñ,‰LäŸ7™7Ÿ<™<¬¯©¯©¸Ó(>ÀÇ	Á	ÓJˆLØÐ+Ó+´2·7±7·>±>À,×3OÑ3OÜ‹L×ÑØ?ØØØ—‘ô	ð ×-Ñ-¨eÓ4ˆFÜ�l EÔ*¨fØ—[‘[ Ô'¨:Ü×&Ò& zÔ:÷ (÷ +ð Ðˆ|Ð÷ (Õ'ú÷ +Ô*ð Ðús$   ÃDÃDÃ1DÄ
D	ÄDÄ
D%c                 ó‚  • SnU R                   U R                  ;  aa  SU R                    S[        U R                  R                  5       5       S3nU R                   S;   a  SR	                  X2/5      n[        U5      eU R                   S:X  aš  [        R                  R                  U5      S   nX@R                  ;  aM  S	U S[        U R                  R                  5       5       S3nUS
;   a  SR	                  X2/5      n[        U5      eU R                  U R                  U      $ U R                  U R                      $ )zà
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Ú ry   éÿÿÿÿzUnrecognized file extension '>   ú.tarú.zip)
r€   ÚmodulesÚlistÚkeysr)   Ú
ValueErrorr&   r'   ÚsplitextÚ
extensions)r   r   Úerror_archivesÚmessageÚexts        r   r„   ÚDecompress._compression_moduleƒ  s+  € ð VˆØ�;‰;˜dŸl™lÓ*à.¨t¯{©{¨mð <#Ü#'¨¯©×(9Ñ(9Ó(;Ó#<Ð"=¸RðAð ð �{‰{˜nÓ,ØŸ(™( GÐ#<Ó=�Ü˜WÓ%Ð%Ø�;‰;˜&Ó Ü—'‘'×"Ñ" 5Ó)¨"Ñ-ˆCØŸ/™/Ó)à3°C°5ð 9'Ü'+¨D¯O©O×,@Ñ,@Ó,BÓ'CÐ&DÀBðHð ð Ð*Ó*Ø!Ÿh™h¨Ð'@ÓA�GÜ  Ó)Ð)Ø—<‘< §¡°Ñ 4Ñ5Ð5Ø�|‰|˜DŸK™KÑ(Ð(r   r   )ry   N)rC   rD   rE   rF   rG   rz   r|   Úbz2r“   r˜   r   rA   r„   rK   r   r   r   rx   rx   $  s6   † ñ)ðV  T°¸tÈcÑR€GØ¨¸Ñ@€Jôò*õX)r   rx   )rG   rI   r&   r�   r|   rz   r…   rs   Úzipfiler   Útarfiler   Úutilsr   ÚABCr   rM   re   rx   r   r   r   Ú<module>r¢      sk   ðñó Û 	Û 
Û Û Û Û 
Ý Ý å ôq˜Ÿ™ô qôhERÐô ERôPLÐô L÷^{)ò {)r   