+
    Bi*                     |   R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIt^ RIHtHtHt ^ RIt^ RIHt ^RIHtHtHt ]P,                  ! R4      t]P1                  ]P2                  ! 4       4       R	 R
 ltR R ltR R ltRR R lltR R ltRR R lltRR R llt ]
RR R ll4       t!R R lt"R# )z
Misc utilities
N)Path)urlsplit)contextmanager)OptionalAny	Generator)Version)	ParsedURLPathTypePathInputTypepoochc                $    V ^8  d   QhR\         /#    return)r   )formats   "I/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pooch/utils.py__annotate__r      s     * *# *    c                 \    ^RI Hp Rp\        P                  ! V\        ^R7       V! V / VB # )a  
WARNING: Importing this function from pooch.utils is DEPRECATED.
Please import from the top-level namespace (`from pooch import file_hash`)
instead, which is fully backwards compatible with pooch >= 0.1.

Examples
--------

>>> fname = "test-file-for-hash.txt"
>>> with open(fname, "w") as f:
...     __ = f.write("content of the file")
>>> print(file_hash(fname))
0fc74468e6a9a829f103d069aeb2bb4f8646bad58bf146bb0e3379b759ec4a00
>>> import os
>>> os.remove(fname)

)	file_hashz
    Importing file_hash from pooch.utils is DEPRECATED. Please import from the
    top-level namespace (`from pooch import file_hash`) instead, which is fully
    backwards compatible with pooch >= 0.1.
    )
stacklevel)hashesr   warningswarnDeprecationWarning)argskwargsnew_file_hashmessages   *,  r   r   r      s1    & 3G
 MM'-!<$)&))r   c                8    V ^8  d   QhR\         P                  /# r   )loggingLogger)r   s   "r   r   r   =   s      GNN r   c                     \         # )a%  
Get the default event logger.

The logger records events like downloading files, unzipping archives, etc.
Use the method :meth:`logging.Logger.setLevel` of this object to adjust the
verbosity level from Pooch.

Returns
-------
logger : :class:`logging.Logger`
    The logger object for Pooch
)LOGGER r   r   
get_loggerr&   =   s	     Mr   c                0    V ^8  d   QhR\         R\        /# )r   projectr   )strr   )r   s   "r   r   r   M   s     6 6c 6d 6r   c                @    \        \        P                  ! V 4      4      # )a  
Default cache location based on the operating system.

The folder locations are defined by the ``platformdirs``  package
using the ``user_cache_dir`` function.
Usually, the locations will be following (see the
`platformdirs documentation <https://platformdirs.readthedocs.io>`__):

* Mac: ``~/Library/Caches/<AppName>``
* Unix: ``~/.cache/<AppName>`` or the value of the ``XDG_CACHE_HOME``
  environment variable, if defined.
* Windows: ``C:\Users\<user>\AppData\Local\<AppAuthor>\<AppName>\Cache``

Parameters
----------
project : str
    The project name.

Returns
-------
cache_path : :class:`pathlib.Path`
    The default location for the data cache. User directories (``'~'``) are
    not expanded.

)r   platformdirsuser_cache_dir)r(   s   &r   os_cacher-   M   s    4 ++G455r   c                <    V ^8  d   QhR\         R\         R\         /# )r   versionfallbackr   r)   )r   s   "r   r   r   j   s!     + +3 +# +S +r   c                <    \        V 4      pVP                  e   V# V # )a  
Check if a version is PEP440 compliant and there are no unreleased changes.

For example, ``version = "0.1"`` will be returned as is but ``version =
"0.1+10.8dl8dh9"`` will return the fallback. This is the convention used by
`versioneer <https://github.com/warner/python-versioneer>`__ to mark that
this version is 10 commits ahead of the last release.

Parameters
----------
version : str
    A version string.
fallback : str
    What to return if the version string has unreleased changes.

Returns
-------
version : str
    If *version* is PEP440 compliant and there are unreleased changes, then
    return *version*. Otherwise, return *fallback*.

Raises
------
InvalidVersion
    If *version* is not PEP440 compliant.

Examples
--------

>>> check_version("0.1")
'0.1'
>>> check_version("0.1a10")
'0.1a10'
>>> check_version("0.1+111.9hdg36")
'master'
>>> check_version("0.1+111.9hdg36", fallback="dev")
'dev'

)r   local)r/   r0   parses   && r   check_versionr5   j   s#    P GE{{Nr   c                0    V ^8  d   QhR\         R\        /# r   urlr   )r)   r	   )r   s   "r   r   r      s     2B 2B3 2B9 2Br   c                $   V P                  R4      '       d   \        RV  R24      hV P                  R4      '       d   RpV R,          P                  R4      pRV^,          P                  4       9   d9   RP	                  VR	,          4      pRRP	                  VR
,          4      ,           pM^RP	                  VRR 4      pRVR,          ,           pM9\        V 4      pVP                  ;'       g    RpVP                  pVP                  pRVRVRV/# )a6  
Parse a URL into 3 components:

<protocol>://<netloc>/<path>

Example URLs:

* http://127.0.0.1:8080/test.nc
* ftp://127.0.0.1:8080/test.nc
* doi:10.6084/m9.figshare.923450.v1/test.nc

The DOI is a special case. The protocol will be "doi", the netloc will be
the DOI, and the path is what comes after the last "/".
The only exception are Zenodo dois: the protocol will be "doi", the netloc
will be composed by the "prefix/suffix" and the path is what comes after
the second "/". This allows to support special cases of Zenodo dois where
the path contains forward slashes "/", created by the GitHub-Zenodo
integration service.

Parameters
----------
url : str
    The URL.

Returns
-------
parsed_url : dict
    Three components of a URL (e.g.,
    ``{'protocol':'http', 'netloc':'127.0.0.1:8080','path': '/test.nc'}``).

zdoi://zInvalid DOI link 'z&'. You must not use '//' after 'doi:'.zdoi:doi:   NN/zenodo:Nr   N:r   NNNfileprotocolnetlocpath)	
startswith
ValueErrorsplitlowerjoinr   schemer@   rA   )r8   r?   partsr@   rA   
parsed_urls   &     r   	parse_urlrK      s    @ ~~h %KL
 	
 ~~fBc"uQx~~''XXeBi(F%),,DXXeCRj)Fr?Dc]
$$..""(FFDAAr   c                t    V ^8  d   QhR\         R\        \        ,          R\        \        ,          R\        /# )r   rA   envr/   r   )r   r   r)   r   )r   s   "r   r   r      s4     $ $
$&sm$=Ec]$	$r   c                   VeJ   V\         P                  9   d5   \         P                  V,          '       d   \         P                  V,          p \        V \        \        34      '       d   \         P
                  P                  ! V !  p Ve*   \         P
                  P                  \        V 4      V4      p \         P
                  P                  \        V 4      4      p \        V 4      # )aN  
Location of the cache given a base path and optional configuration.

Checks for the environment variable to overwrite the path of the local
cache. Optionally add *version* to the path if given.

Parameters
----------
path : str, PathLike, list or tuple
    The path to the local data storage folder. If this is a list or tuple,
    we'll join the parts with the appropriate separator. Use
    :func:`pooch.os_cache` for a sensible default.
version : str or None
    The version string for your project. Will be appended to given path if
    not None.
env : str or None
    An environment variable that can be used to overwrite *path*. This
    allows users to control where they want the data to be stored. We'll
    append *version* to the end of this value as well.

Returns
-------
local_path : PathLike
    The path to the local directory.

)
osenviron
isinstancelisttuplerA   rG   r)   
expanduserr   )rA   rM   r/   s   &&&r   cache_locationrU      s    : 3"**,Czz#$u&&ww||T"ww||CIw/77c$i(D:r   c                J    V ^8  d   QhR\         R\        \        ,          RR/# )r   rA   rM   r   N)r
   r   r)   )r   s   "r   r   r      s%     &< &<X &<HSM &<T &<r   c                   \        V 4      p \        P                  P                  V 4      '       g   RpMRp VR8X  d   \        P                  ! V RR7       R# \
        P                  ! V R7      ;_uu_ 4         RRR4       R#   + '       g   i     R# ; i  \         dO   p\        T4      RT RT  R	2R
.pTe   TP                  RT R24       \        RP                  T4      4      ThRp?ii ; i)a7  
Create the local cache directory and make sure it's writable.

Parameters
----------
path : str or PathLike
    The path to the local data storage folder.
env : str or None
    An environment variable that can be used to overwrite *path*. Only used
    in the error message in case the folder is not writable.
createzwrite toT)exist_ok)dirNz| Pooch could not z data cache folder 'z'.z(Will not be able to download data files.zUse environment variable 'z"' to specify a different location. )
r)   rO   rA   existsmakedirstempfileNamedTemporaryFilePermissionErrorappendrG   )rA   rM   actionerrorr   s   &&   r   make_local_storagerd      s     t9D77>>$<X KKt,,,66 7666 
<J (<TF"E6

 ?NN,SE1ST chhw/0e;
<s<   B B 7B9B B	B B C0"A	C++C0c                b    V ^8  d   QhR\         \        ,          R\        \        RR3,          /# )r   rA   r   N)r   r
   r   r)   )r   s   "r   r   r     s*        (+  ydD7Q  r   c              #    "   \         P                  ! RV R7      pVP                  4         VP                  x  \        P
                  P                  VP                  4      '       d#   \        P                  ! VP                  4       R# R#   \        P
                  P                  TP                  4      '       d"   \        P                  ! TP                  4       i i ; i5i)a  
Create a closed and named temporary file and make sure it's cleaned up.

Using :class:`tempfile.NamedTemporaryFile` will fail on Windows if trying
to open the file a second time (when passing its name to Pooch function,
for example). This context manager creates the file, closes it, yields the
file path, and makes sure it's deleted in the end.

Parameters
----------
path : str or PathLike
    The directory in which the temporary file will be created.

Yields
------
fname : str
    The path to the temporary file.

F)deleterZ   N)r^   r_   closenamerO   rA   r\   remove)rA   tmps   & r   temporary_filerl     s     * 
%
%U
=CIIK hh77>>#((##IIchh $277>>#((##IIchh $s   )C"B AC"ACC"c                0    V ^8  d   QhR\         R\         /# r7   r1   )r   s   "r   r   r   <  s     ( (# (# (r   c                   \         P                  ! V P                  4       RR7      P                  4       p\	        V 4      R,          P                  R4      R,          pV^\        V4      ,
          ^,
          ) R pV RV 2pV# )a  
Create a unique file name based on the given URL.

The file name will be unique to the URL by prepending the name with the MD5
hash (hex digest) of the URL. The name will also include the last portion
of the URL.

The format will be: ``{md5}-{filename}.{ext}``

The file name will be cropped so that the entire name (including the hash)
is less than 255 characters long (the limit on most file systems).

Parameters
----------
url : str
    The URL with a file name at the end.

Returns
-------
fname : str
    The file name, unique to this URL.

Examples
--------

>>> print(unique_file_name("https://www.some-server.org/2020/data.txt"))
02ddee027ce5ebb3d7059fb23d210604-data.txt
>>> print(unique_file_name("https://www.some-server.org/2019/data.txt"))
9780092867b497fca6fc87d8308f1025-data.txt
>>> print(unique_file_name("https://www.some-server.org/2020/data.txt.gz"))
181a9d52e908219c2076f55145d6a344-data.txt.gz

F)usedforsecurityrA   r<   N-rB   )hashlibmd5encode	hexdigestrK   rE   len)r8   rr   fnameunique_names   &   r   unique_file_namerx   <  sw    D ++cjjlE
:
D
D
FCcN6"((-b1E C#c(NQ&')*EE5'"Kr   )master)NN)N)#__doc__r!   rO   r^   rq   pathlibr   urllib.parser   
contextlibr   r   typingr   r   r   r+   packaging.versionr   r	   r
   r   r"   r$   
addHandlerStreamHandlerr   r&   r-   r5   rK   rU   rd   rl   rx   r%   r   r   <module>r      s     	    ! %  + +  % 6 6 
	    ''') **< 6:+\2Bj$N&<R    <(r   