
    &=d                         d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
ddlmZ ddlmZ dez   dz   ZddZdd	Zd
 ZdS )    N   )	NoNetwork)VERSION_NUMBERz
reportbug/z	 (Debian)<   c                     |st           j                                        }t          dd}t	          j        | |||          j        S )ad  
    Open an URL and return the content

    This is a helper function for :func:`open_url()`.

    Parameters
    ----------
    url : str
        The URL to retrieve
    proxies : dict
        proxies to use
    timeout : int
        request timeout in seconds
    data
        unused

    Returns
    -------
    str
        Content of the response
    z)gzip;q=1.0, deflate;q=0.9, identity;q=0.5)z
User-AgentzAccept-Encoding)headersproxiestimeout)urllibrequest
getproxiesUA_STRrequestsgettext)urlr	   r
   datar   s        4/usr/lib/python3/dist-packages/reportbug/urlutils.pyurlopenr   +   sQ    ,  ..++--#"MO OG <WgwOOOTT    c                    t          j        |           t          j                                        }|r
||d<   ||d<   	 t          | ||          }n# t          j        j        $ r}|j        dv rY d}~dS  d}~wt           j	        t           j        t          j        j
        f$ r t          t          $ r,}|r|d         dk    r|d         dk    rY d}~dS t          d}~wt          $ r# t          d	t          j        
           t          t"          j        j        $ r,}|j        j        }d|  d| d| d}	t          |	          d}~ww xY w|S )a  
    Open an URL and return the content

    Parameters
    ----------
    url : str
        The URL to retrieve
    http_proxy : str
        HTTP proxy server URL to use for connection.
        By default, use the :func:`urllib.request.getproxies()` settings.
    timeout : int
        connection timeout in seconds

    Returns
    -------
    str
        Content of the response
    httphttps)  i  i  Nr   z
http errorr   r   z@http_proxy environment variable must be formatted as a valid URI)filezFailed to open z (z: ))socketsetdefaulttimeoutr   r   r   r   error	HTTPErrorcodegaierrorURLErrorr   OSError	TypeErrorprintsysstderrr   clientHTTPException	__class____name__)
r   
http_proxyr
   r	   pagexr   excexc_namemessages
             r   open_urlr3   L   s   * W%%%n''))G &$%!sGW--<!   6_$$44444OV\6<+@A       	DG|++Q344444O   PWZWabbbb;$ ! ! !=)=C==8==s===   ! Ks=    A E	&	A65A66>E	4CCAE	'EE	c                     t          j        d          s-dt          j        |           z   }t          j        |           dS t          rt	          j        |            dS dS )z
    Launch a web browser to view an URL

    Parameters
    ----------
    url : str
        The URL to view

    Returns
    -------
    None
    z#command -v xdg-open >/dev/null 2>&1z	xdg-open N)ossystemshlexquote
webbrowseropen)r   cmds     r   launch_browserr<      sd     9:;; EK,,,
	#  r   )Nr   N)Nr   )http.clientr   urllib.requestr   urllib.errorr   r7   r5   r'   r9   r   
exceptionsr   __init__r   r   r   r3   r<    r   r   <module>rC      s   0               				 



           % $ $ $ $ $		&	4U U U UB1 1 1 1h    r   