
    |h                         d dl Zd dlZd dlmZmZ d dlZd dlZd dlZd dl	m
Z
  ej                  d      Zd Ze
d        Zy)    N)URLError	HTTPError)contextmanagerz'http://|https://|ftp://|file://|file:\\c                 T    t        | t              xr t        j                  |       duS )z-Return True if string is an http or ftp path.N)
isinstancestr	URL_REGEXmatch)filenames    N/var/www/html/test/engine/venv/lib/python3.12/site-packages/skimage/io/util.pyis_urlr      s"    h$N)B$)NN    c              #     K   t        |       rt        j                  j                  |       }t        j
                  j                  |j
                        \  }}	 t        j                  d|      5 }t        j                  j                  |       5 }|j                  |j                                ddd       ddd       j                   t	        j                  |j                         y|  y# 1 sw Y   DxY w# 1 sw Y   HxY w# t        t         f$ r! t	        j                  j                          t"        t$        t&        t(        f$ r  w xY ww)z>Yield name of file from the given resource (i.e. file or url).F)deletesuffixN)r   urllibparseurlparseospathsplitexttempfileNamedTemporaryFilerequesturlopenwritereadnameremover   r   FileNotFoundErrorFileExistsErrorPermissionErrorBaseException)resource_nameurl_components_extfus         r   file_or_url_contextr*      s     m..}=!!."5"563	,,E#F &!^^++M: &aGGAFFH%&& &&L IIaff& && &
 )$ 	IIaff!?O]S 		sO   AED 1 D  C41D 9D %E4C=	9D  D	D A	EE)urllib.parser   urllib.requesturllib.errorr   r   r   rer   
contextlibr   compiler	   r   r*    r   r   <module>r2      sG      , 	 	  % BJJAB	O
  r   