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mZ ddlmZ dZd	d
 Zdd Zdd Zdd Zdd ZdS )z

    )absolute_importdivisionprint_functionunicode_literalsN)warn   )Document)BaseResources)bundle_for_objs_and_resourcesc       
      C   s|  t |tr| }}n^t |trft|dkrftdd |D rf|\}}|rT|sTtd |rr|srtd ntd| ddlm} | rt	| nd	}| rt
| nd	}| rt| nd	}|r||}|sd
|jkr|jd
 |sd|jkr|jd |sd|jkr|jd | }nd}|rp||}|sHd
|jkrH|jd
 |sfd|jkrf|jd | }	nd}	||	fS )z Generate rendered CSS and JS resources suitable for the given
    collection of Bokeh objects

    Args:
        objs (seq[Model or Document]) :

        resources (BaseResources or tuple[BaseResources])

    Returns:
        tuple

    r   c             s   s    | ]}|d kpt |tV  qd S )N)
isinstancer	   ).0r r   1lib/python3.7/site-packages/bokeh/embed/bundle.py	<genexpr>?   s    z0bundle_for_objs_and_resources.<locals>.<genexpr>z`No Bokeh CSS Resources provided to template. If required you will need to provide them manually.z_No Bokeh JS Resources provided to template. If required you will need to provide them manually.z:expected Resources or a pair of optional Resources, got %rr   )deepcopyTzbokeh-widgetszbokeh-tableszbokeh-glN)r   r	   tuplelenallr   
ValueErrorcopyr   _use_widgets_use_tables_use_glZjs_componentsremoveZ	render_jsZcss_componentsZ
render_css)
objs	resourcesZjs_resourcesZcss_resourcesr   Zuse_widgetsZ
use_tablesZuse_glZbokeh_jsZ	bokeh_cssr   r   r   r
   0   s@    

(


r
   c                sP   xJ| D ]>}t |tr&t|j rDdS qt fdd| D rdS qW dS dS )z Whether any of a collection of objects satisfies a given query predicate

    Args:
        objs (seq[Model or Document]) :

        query (callable)

    Returns:
        True, if ``query(obj)`` is True for some object in ``objs``, else False

    Tc             3   s   | ]} |V  qd S )Nr   )r   ref)queryr   r   r   ~   s    z_any.<locals>.<genexpr>FN)r   r   _anyrootsanyZ
references)r   r   objr   )r   r   r   m   s    

r   c                s   ddl m  t|  fddS )z Whether a collection of Bokeh objects contains a plot requesting WebGL

    Args:
        objs (seq[Model or Document]) :

    Returns:
        bool

    r   )Plotc                s   t |  o| jdkS )NZwebgl)r   Zoutput_backend)r"   )r#   r   r   <lambda>   s    z_use_gl.<locals>.<lambda>)Zmodels.plotsr#   r   )r   r   )r#   r   r      s    
r   c                s   ddl m  t|  fddS )z Whether a collection of Bokeh objects contains a TableWidget

    Args:
        objs (seq[Model or Document]) :

    Returns:
        bool

    r   )TableWidgetc                s
   t |  S )N)r   )r"   )r%   r   r   r$      s    z_use_tables.<locals>.<lambda>)models.widgetsr%   r   )r   r   )r%   r   r      s    
r   c                s   ddl m  t|  fddS )z Whether a collection of Bokeh objects contains a any Widget

    Args:
        objs (seq[Model or Document]) :

    Returns:
        bool

    r   )Widgetc                s
   t |  S )N)r   )r"   )r'   r   r   r$      s    z_use_widgets.<locals>.<lambda>)r&   r'   r   )r   r   )r'   r   r      s    
r   )__doc__Z
__future__r   r   r   r   ZloggingZ	getLogger__name__logwarningsr   Zdocument.documentr   r   r	   __all__r
   r   r   r   r   r   r   r   r   <module>	   s   
=