B
    @\                 @   s   d Z ddlmZmZmZmZ ddlZeeZ	ddl
mZ ddlZddlmZ dddZd	ZG d
d deZdddZdddZdS )zD Utility functions for helping with operations involving browsers.

    )absolute_importdivisionprint_functionunicode_literalsN)abspath   )settings   )tabwindow)DummyWebBrowserget_browser_controllerviewc               @   s   e Zd ZdZdddZdS )r   z( A "no-op" web-browser controller.

    r   Tc             C   s   dS )z0 Receive standard arguments and take no action. N )selfurlnew	autoraiser   r   1lib/python3.7/site-packages/bokeh/util/browser.pyopen4   s    zDummyWebBrowser.openN)r   T)__name__
__module____qualname____doc__r   r   r   r   r   r   0   s   r   c             C   s6   t | } | dk	r.| dkr"t }q2t| }nt}|S )aV   Return a browser controller.

    Args:
        browser (str or None) : browser name, or ``None`` (default: ``None``)
            If passed the string ``'none'``, a dummy web browser controller
            is returned

            Otherwise, use the value to select an appropriate controller using
            the ``webbrowser`` standard library module. In the value is
            ``None`` then a system default is used.

    .. note::
        If the environment variable ``BOKEH_BROWSER`` is set, it will take
        precedence.

    Returns:
        controller : a web browser controller

    NZnone)r   browserr   
webbrowserget)r   
controllerr   r   r   r   8   s    
r   sameTc          	   C   s   ydddd| }W n  t k
r4   td| Y nX | drF| }ndt|  }yt|}|j|||d W n$ ttfk
r    Y n   Y nX d	S )
a   Open a browser to view the specified location.

        Args:
            location (str) : Location to open
                If location does not begin with "http:" it is assumed
                to be a file path on the local filesystem.
            browser (str or None) : what browser to use (default: None)
                If ``None``, use the system default browser.
            new (str) : How to open the location. Valid values are:

                ``'same'`` - open in the current tab

                ``'tab'`` - open a new tab in the current window

                ``'window'`` - open in a new window
            autoraise (bool) : Whether to automatically raise the location
                in a new browser window (default: True)

        Returns:
            None

        r   r	   r   )r   r   r
   zTinvalid 'new' value passed to view: %r, valid values are: 'same', 'window', or 'tab'Zhttpzfile://)r   r   N)KeyErrorRuntimeError
startswithr   r   r   
SystemExitKeyboardInterrupt)locationr   r   r   r   r   r   r   r   r   X   s    
r   )N)Nr   T)r   Z
__future__r   r   r   r   ZloggingZ	getLoggerr   logos.pathr   r   r   Z	NEW_PARAM__all__objectr   r   r   r   r   r   r   <module>	   s   

	
 