o
    h!                     @   sf   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dZdd Ze
dd ZdS )	    N)URLError	HTTPError)contextmanagerz'http://|https://|ftp://|file://|file:\\c                 C   s   t | tot| duS )z-Return True if string is an http or ftp path.N)
isinstancestr	URL_REGEXmatch)filename r
   J/var/www/html/scripts/venv/lib/python3.10/site-packages/skimage/io/util.pyis_url   s   
r   c                 c   s    t | rrtj| }tj|j\}}z:tjd|d%}tj	
| }||  W d   n1 s5w   Y  W d   n1 sDw   Y  |jV  W n ttfy^   t|j   ttttfyi    w t|j dS | 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namer   r   removeFileNotFoundErrorFileExistsErrorPermissionErrorBaseException)resource_nameurl_components_extfur
   r
   r   file_or_url_context   s,   

r'   )urllib.parser   urllib.requesturllib.errorr   r   r   rer   
contextlibr   compiler   r   r'   r
   r
   r
   r   <module>   s    
