
    1-Ph                         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dS )    N)URLError	HTTPError)contextmanagerz'http://|https://|ftp://|file://|file:\\c                 d    t          | t                    ot                              |           duS )z-Return True if string is an http or ftp path.N)
isinstancestr	URL_REGEXmatch)filenames    O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/io/util.pyis_urlr      s(    h$$N)B)B$)NN    c              #     K   t          |           rCt          j                            |           }t          j                            |j                  \  }}	 t          j        d|          5 }t          j	        
                    |           5 }|                    |                                           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        V  t	          j        |j                   dS # t          t           f$ r t	          j        |j                    t"          t$          t&          t(          f$ r  w xY w| V  dS )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663	,E#FFF &!^++M:: &aGGAFFHH%%%& & & & & & & & & & & & & & && & & & & & & & & & & & & & & &LLL Iaf )$ 	 	 	Iaf!?O]S 	 	 		 sU   D
 0 C(C8CC	CC	CD
 CD
 "C#D
 
A	E)urllib.parser   urllib.requesturllib.errorr   r   r   rer   
contextlibr   compiler	   r   r*    r   r   <module>r2      s            , , , , , , , , 				 				  % % % % % % BJABB	O O O
     r   