§
    +Áôgq  ã                   óÜ   — 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mZ ddlm	Z	 ddl
mZ ddlmZmZ d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Ze	ej        fd„¦   «         Ze	d„ ¦   «         Zd„ Zd„ ZdS )z
Utilities for testing code.
é    N)ÚPath)Úcontextmanageré   )Ú__version__)Úcheck_versionÚ
get_loggerc                 ó$  — t           j                             | ¦  «        sJ ‚t          | d¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   d                     ddg¦  «        }|                     ¦   «         |k    sJ ‚dS )zN
    Load the tiny-data.txt file and check that the contents are correct.
    úutf-8©ÚencodingNú
z)# A tiny data file for test purposes onlyú1  2  3  4  5  6)ÚosÚpathÚexistsÚopenÚreadÚjoinÚstrip)ÚfnameÚtinydataÚcontentÚtrue_contents       úZ/var/www/html/bac/bac_backend/python/env/lib/python3.11/site-packages/pooch/tests/utils.pyÚcheck_tiny_datar      sÍ   € õ Œ7�>Š>˜%Ñ Ô Ð Ð Ð Ý	ˆe˜gÐ	&Ñ	&Ô	&ð "¨(Ø—-’-‘/”/ˆð"ð "ð "ñ "ô "ð "ð "ð "ð "ð "ð "øøøð "ð "ð "ð "à—9’9Ø	4Ð6HÐIñô €Lð �=Š=‰?Œ?˜lÒ*Ð*Ð*Ð*Ð*Ð*ó   ³AÁAÁAc                 óT  — t           j                             | ¦  «        sJ ‚t          | d¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   dg}|                     dgdz  ¦  «         |                     ¦   «         d                     |¦  «        k    sJ ‚dS )zO
    Load the large-data.txt file and check that the contents are correct.
    r
   r   Nz*# A larer data file for test purposes onlyr   ir  r   )r   r   r   r   r   Úextendr   r   )r   Údatar   r   s       r   Úcheck_large_datar    #   sà   € õ Œ7�>Š>˜%Ñ Ô Ð Ð Ð Ý	ˆe˜gÐ	&Ñ	&Ô	&ð ¨$Ø—)’)‘+”+ˆðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð à@ÐA€LØ×ÒÐ+Ð,¨tÑ3Ñ4Ô4Ð4Ø�=Š=‰?Œ?˜dŸiši¨Ñ5Ô5Ò5Ð5Ð5Ð5Ð5Ð5r   c                  ó>   — t          t          d¬¦  «        } d| › d�}|S )as  
    Get the base URL for the test data used in Pooch itself.

    The URL is a GitHub raw link to the ``pooch/tests/data`` directory from the
    `GitHub repository <https://github.com/fatiando/pooch>`__. It matches the
    pooch version specified in ``pooch.version.full_version``.

    Returns
    -------
    url
        The versioned URL for pooch's test data.

    Úmain)Úfallbackz&https://github.com/fatiando/pooch/raw/z/pooch/tests/data/)r   Úfull_version)ÚversionÚurls     r   Úpooch_test_urlr'   /   s+   € õ �L°6Ð:Ñ:Ô:€GØ
N°7Ð
NÐ
NÐ
N€CØ€Jó    c                  ó
   — d} | S )zý
    Get the base URL for the test data stored in figshare.

    The URL contains the DOI for the figshare dataset using the appropriate
    version for this version of Pooch.

    Returns
    -------
    url
        The URL for pooch's test data.

    z$doi:10.6084/m9.figshare.14763051.v1/© ©r&   s    r   Úpooch_test_figshare_urlr,   B   s   € ð 1€CØ€Jr(   c                  ó
   — d} | S )zù
    Get the base URL for the test data stored in Zenodo.

    The URL contains the DOI for the Zenodo dataset using the appropriate
    version for this version of Pooch.

    Returns
    -------
    url
        The URL for pooch's test data.

    zdoi:10.5281/zenodo.4924875/r*   r+   s    r   Úpooch_test_zenodo_urlr.   S   s   € ð (€CØ€Jr(   c                  ó
   — d} | S )aj  
    Get base URL for test data in Zenodo, where the file name contains a slash

    The URL contains the DOI for the Zenodo dataset that has a slash in the
    filename (created with the GitHub-Zenodo integration service), using the
    appropriate version for this version of Pooch.

    Returns
    -------
    url
        The URL for pooch's test data.

    zdoi:10.5281/zenodo.7632643/r*   r+   s    r   Ú pooch_test_zenodo_with_slash_urlr0   d   s   € ð (€CØ€Jr(   c                  ó
   — d} | S )z”
    Get the base URL for the test data stored on a DataVerse instance.

    Returns
    -------
    url
        The URL for pooch's test data.
    zdoi:10.11588/data/TKCFEF/r*   r+   s    r   Úpooch_test_dataverse_urlr2   v   s   € ð &€CØ€Jr(   c                  ó    — dddddddddd	d
œ
} | S )z©
    Get a registry for the test data used in Pooch itself.

    Returns
    -------
    registry
        Dictionary with pooch's test data files and their hashes.

    Ú@baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2dÚ@98de171fb320da82982e6bf0f3994189fff4b42b23328769afce12bdd340444aÚ@0d49e94f07bc1866ec57e7fd1b93a351fba36842ec9b13dd50bf94e8dfa35cbbÚ@0498d2a001e71051bbd2acd2346f38da7cbd345a633cb7bf0f8a20938714b51aÚ@41503f083814f43a01a8e9a30c28d7a9fe96839a99727a7fdd0acf7cd5bab63bÚ@088c7f4e0f1859b1c769bb6065de24376f366374817ede8691a6ac2e49f29511Ú@753663687a4040c90c8578061867d1df623e6aa8011c870a5dbd88ee3c82e306Ú@2e2da6161291657617c32192dba95635706af80c6e7335750812907b58fd4b52Ú@99dcb5c32a6e916344bacb4badcbc2f2b6ee196977d1d8187610c21e7e607765)
ztiny-data.txtzlarge-data.txtzsubdir/tiny-data.txtztiny-data.zipz	store.zipztiny-data.tar.gzzstore.tar.gzztiny-data.txt.bz2ztiny-data.txt.gzztiny-data.txt.xzr*   )Úregistrys    r   Úpooch_test_registryr>   ƒ   s6   € ð \Ø\Ø bØ[ØWØ^ØZØ_Ø^Ø^ðð €Hð €Or(   c              #   ó  K  — t          j        ¦   «         }t          j        |¦  «        }|                     | ¦  «         t          ¦   «                              |¦  «         |V — t          ¦   «                              |¦  «         dS )z¦
    Create a context manager for reading from the logs.

    Yields
    ------
    log_file : StringIO
        a file-like object to which the logs were written
    N)ÚioÚStringIOÚloggingÚStreamHandlerÚsetLevelr   Ú
addHandlerÚremoveHandler)ÚlevelÚlog_fileÚhandlers      r   Úcapture_logrJ   œ   sv   è è € õ Œ{‰}Œ}€HÝÔ# HÑ-Ô-€GØ×Ò�UÑÔÐÝ�L„L×Ò˜GÑ$Ô$Ð$Ø
€N€N€NÝ�L„L×Ò˜wÑ'Ô'Ð'Ð'Ð'r(   c              #   óÆ  K  — t          t          t          ¦  «        j        dz  |z  ¦  «        }t          j                             | j        |¦  «        }	 t          j	        ||¦  «         d|› �}|V — t          j         
                    |¦  «        rt	          j        |¦  «         dS dS # t          j         
                    |¦  «        rt	          j        |¦  «         w w xY w)aÀ  
    Add a test data file to the test FTP server and clean it up afterwards.

    Parameters
    ----------
    server
        The ``ftpserver`` fixture provided by pytest-localftpserver.
    fname : str
        The name of a file *relative* to the test data folder of the package
        (usually just the file name, not the full path).

    Yields
    ------
    url : str
        The download URL of the data file from the test FTP server.

    r   zftp://localhost/N)Ústrr   Ú__file__Úparentr   r   r   Ú	anon_rootÚshutilÚcopyfiler   Úremove)Úserverr   Úpackage_pathÚserver_pathr&   s        r   Údata_over_ftprV   ®   sÔ   è è € õ& •t�H‘~”~Ô,¨vÑ5¸Ñ=Ñ>Ô>€LÝ”'—,’,˜vÔ/°Ñ7Ô7€Kð#ÝŒ˜ kÑ2Ô2Ð2Ø( Ð(Ð(ˆØˆ	ˆ	ˆ	åŒ7�>Š>˜+Ñ&Ô&ð 	#ÝŒI�kÑ"Ô"Ð"Ð"Ð"ð	#ð 	#ø�2Œ7�>Š>˜+Ñ&Ô&ð 	#ÝŒI�kÑ"Ô"Ð"Ð"ð	#øøøs   ÁB* Â*6C c                 óÚ   — |                       ¦   «         D ]U}|                     ¦   «         r?|                     |                     ¦   «         j        |z  ¦  «         t          ||¦  «         ŒVdS )zg
    Recursively change the permissions on the child directories using a bitwise
    OR operation.
    N)ÚiterdirÚis_dirÚchmodÚstatÚst_modeÚ_recursive_chmod_directories)ÚrootÚmodeÚitems      r   r]   r]   Ì   sh   € ð
 —’‘”ð 5ð 5ˆØ�;Š;‰=Œ=ð 	5Ø�JŠJ�t—y’y‘{”{Ô*¨TÑ1Ñ2Ô2Ð2Ý(¨¨tÑ4Ô4Ð4øð5ð 5r(   c                 ó²   — t          | ¦  «        } t          |¦  «        | j        z  }t          j        | |¦  «         t	          |t
          j        ¬¦  «         |S )aä  
    Copy contents of the source directory into destination and fix permissions.

    Parameters
    ----------
    source : str, :class:`pathlib.Path`
        Source data directory.
    destination : str, :class:`pathlib.Path`
        Destination directory that will contain the copy of source. The actual
        source directory (not just it's contents) is copied.

    Returns
    -------
    mirror : :class:`pathlib.Path`
        The path of the mirrored output directory.

    )r_   )r   ÚnamerP   Úcopytreer]   r[   ÚS_IWUSR)ÚsourceÚdestinationÚmirrors      r   Úmirror_directoryrh   ×   sO   € õ$ �&‰\Œ\€FÝ�+ÑÔ ¤Ñ,€FÝ
„O�F˜FÑ#Ô#Ð#Ý  ­d¬lÐ;Ñ;Ô;Ð;Ø€Mr(   )Ú__doc__r   r@   rB   rP   r[   Úpathlibr   Ú
contextlibr   Ú r   r$   Úutilsr   r   r   r    r'   r,   r.   r0   r2   r>   ÚDEBUGrJ   rV   r]   rh   r*   r(   r   ú<module>ro      sl  ððð ð 
€	€	€	Ø 	€	€	€	Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à *Ð *Ð *Ð *Ð *Ð *Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -ð
+ð 
+ð 
+ð	6ð 	6ð 	6ðð ð ð&ð ð ð"ð ð ð"ð ð ð$
ð 
ð 
ðð ð ð2 Ø”mð (ð (ð (ñ „ð(ð" ð#ð #ñ „ð#ð:5ð 5ð 5ðð ð ð ð r(   