ó
mÜJ]c           @` sÓ   d  Z  d d l m Z m Z m Z m Z d d l Z e j e ƒ Z	 d d l
 m Z d d l m Z d d l m Z d d l m Z d	 d
 l m Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   u   

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   warni   (   t   Document(   t   BaseResources(   t   bundle_modelsi   (   t   wrap_in_script_tagu   bundle_for_objs_and_resourcesc         C` s›  t  | t ƒ r | } } nŠ t  | t ƒ r– t | ƒ d k r– t d „  | Dƒ ƒ r– | \ } } | ry | ry t d ƒ n  | r¦ | r¦ t d ƒ q¦ n t d | ƒ ‚ d d l m } |  rÈ t	 |  ƒ n t
 } |  rà t |  ƒ n t
 } |  rø t |  ƒ n t
 } | rš| | ƒ } | r9d | j k r9| j j d ƒ n  | rbd	 | j k rb| j j d	 ƒ n  | r‹d
 | j k r‹| j j d
 ƒ n  | j ƒ  } n d } |  rÈg  t |  ƒ D] }	 |	 j ^ q³n d }
 t |
 ƒ } | d k	 rt | ƒ } | d k	 r| d | 7} q| } n  | r‹| | ƒ } | rSd | j k rS| j j d ƒ n  | r|d	 | j k r|| j j d	 ƒ n  | j ƒ  } n d } | | f S(   uî    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

    i   c         s` s*   |  ]  } | d  k p! t | t ƒ Vq d  S(   N(   t   Nonet
   isinstanceR   (   t   .0t   r(    (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pys	   <genexpr>A   s    u`   No Bokeh CSS Resources provided to template. If required you will need to provide them manually.u_   No Bokeh JS Resources provided to template. If required you will need to provide them manually.u:   expected Resources or a pair of optional Resources, got %ri    (   t   deepcopyu   bokeh-widgetsu   bokeh-tablesu   bokeh-glu   
N(   R
   R   t   tuplet   lent   allR   t
   ValueErrort   copyR   t   _use_widgetst   Truet   _use_tablest   _use_glt   js_componentst   removet	   render_jsR	   t	   _all_objst	   __class__R   R   t   css_componentst
   render_css(   t   objst	   resourcest   js_resourcest   css_resourcesR   t   use_widgetst
   use_tablest   use_glt   bokeh_jst   objt   modelst   custom_bundlet	   bokeh_css(    (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyt   bundle_for_objs_and_resources2   sN    7.	c         C` sd   t  ƒ  } xT |  D]L } t | t ƒ rL x4 | j D] } | | j ƒ  O} q/ Wq | | j ƒ  O} q W| S(   N(   t   setR
   R   t   rootst
   references(   R   t   all_objsR&   t   root(    (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR   z   s    	c         ` sg   x` |  D]T } t  | t ƒ r5 t | j ˆ  ƒ r[ t Sq t ‡  f d †  | j ƒ  Dƒ ƒ r t Sq Wt Sd S(   uú    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

    c         3` s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   R   t   ref(   t   query(    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pys	   <genexpr>—   s    N(   R
   R   t   _anyR,   R   t   anyR-   t   False(   R   R1   R&   (    (   R1   s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR2   †   s    "c         ` s&   d d l  m ‰  t |  ‡  f d †  ƒ S(   u›    Whether a collection of Bokeh objects contains a plot requesting WebGL

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

    Returns:
        bool

    i   (   t   Plotc         ` s   t  |  ˆ  ƒ o |  j d k S(   Nu   webgl(   R
   t   output_backend(   R&   (   R5   (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyt   <lambda>§   t    (   t   models.plotsR5   R2   (   R   (    (   R5   s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR   œ   s    
c         ` s&   d d l  m ‰  t |  ‡  f d †  ƒ S(   u‘    Whether a collection of Bokeh objects contains a TableWidget

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

    Returns:
        bool

    i   (   t   TableWidgetc         ` s   t  |  ˆ  ƒ S(   N(   R
   (   R&   (   R:   (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR7   ´   R8   (   t   models.widgetsR:   R2   (   R   (    (   R:   s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR   ©   s    
c         ` s&   d d l  m ‰  t |  ‡  f d †  ƒ S(   u    Whether a collection of Bokeh objects contains a any Widget

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

    Returns:
        bool

    i   (   t   Widgetc         ` s   t  |  ˆ  ƒ S(   N(   R
   (   R&   (   R<   (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR7   Á   R8   (   R;   R<   R2   (   R   (    (   R<   s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyR   ¶   s    
(   u   bundle_for_objs_and_resources(   t   __doc__t
   __future__R    R   R   R   t   loggingt	   getLoggert   __name__t   logt   warningsR   t   document.documentR   R   R   t   util.compilerR   t   wrappersR   t   __all__R*   R   R2   R   R   R   (    (    (    s1   lib/python2.7/site-packages/bokeh/embed/bundle.pyt   <module>	   s   "	H				