B
    \                 @   s   yd dl mZ W n  ek
r0   d dlmZ Y nX d dlZd dlZd dlZd dlmZ d dl	Z	e
dZdd Zedd ZdS )	    )urlopenN)contextmanagerz'http://|https://|ftp://|file://|file:\\c             C   s   t | tjot| dk	S )z-Return True if string is an http or ftp path.N)
isinstancesixZstring_types	URL_REGEXmatch)filename r	   .lib/python3.7/site-packages/skimage/io/util.pyis_url   s    r   c          	   c   sp   t | rftj| \}}z<tjd|d}t| }||  W dQ R X |j	V  W dt
|j	 X n| V  dS )z>Yield name of file from the given resource (i.e. file or url).F)deletesuffixN)r   ospathsplitexttempfileZNamedTemporaryFiler   writereadnameremove)resource_name_Zextfur	   r	   r
   file_or_url_context   s    r   )Zurllib.requestr   ImportErrorZurllib2r   rer   
contextlibr   r   compiler   r   r   r	   r	   r	   r
   <module>   s   
