
    +d                     F    d dl Zd dlmZ ddlmZmZ  G d de          ZdS )    Nremake_instance   )BaseSelectorcoerce_to_listc                   z     e Zd ZdZdZg Zd
 fd	Zd Zed             Z	e	j
        d             Z	d Zd Zd	 Z xZS )SourceSelectora  
    The source selector takes a variety of inputs such as cats or sources
    and uses those to populate a select widget containing all the sources.

    Once the source selector is populated with these options, the user can
    select which source(s) are of interest. These sources are stored on
    the ``selected`` property of the class.

    Parameters
    ----------
    cats: list of catalogs, opt
        catalogs used to initalize, provided as objects.
    sources: list of sources, opt
        sources used to initalize, provided as objects.
    done_callback: func, opt
        called when the object's main job has completed. In this case,
        selecting source(s).

    Attributes
    ----------
    selected: list of sources
        list of selected sources
    items: list of sources
        list of all the source values represented in widget
    labels: list of str
        list of labels for all the sources represented in widget
    options: dict
        dict of widget labels and values (same as `dict(zip(self.labels, self.values))`)
    children: list of panel objects
        children that will be used to populate the panel when visible
    panel: panel layout object
        instance of a panel layout (row or column) that contains children
        when visible
    watchers: list of param watchers
        watchers that are set on children - cleaned up when visible
        is set to false.
    Nc                     t          j        dd          | _        t           j                            ddd          | _        || _         t                      j        d	i | |	|| _	        dS |	|| _
        dS dS )
a  Set sources or cats to initialize the class - sources trumps cats.

        The order of the calls in this method matters and is different
        from the order in other panel init methods because the top level
        gui class needs to be able to watch these widgets.
        zSelect Data Sourcer   )namemargin	      min)size	min_widthwidth_policyN )pnColumnpanelwidgetsMultiSelectwidgetdone_callbacksuper__init__itemscats)selfsourcesr   r   kwargs	__class__s        >lib/python3.11/site-packages/intake/interface/source/select.pyr   zSourceSelector.__init__9   s     Y$8CCC
j,,!sQV,WW*""6""" 	 DJJJ 	DIII	 	    c                     t           j                            dd          }| j        j                            | j        d          g| _        || j        g| _        d S )Nz#### Sources(   )
max_heightvalue)	r   paneMarkdownr   paramwatchcallbackwatcherschildren)r   labels     r#   setupzSourceSelector.setupJ   sS      B ??K##DM7;;
 ,r$   c                 >    t          d | j        D                       S )z'Cats represented in the sources optionsc              3   $   K   | ]}|j         V  d S N)_catalog.0sources     r#   	<genexpr>z&SourceSelector.cats.<locals>.<genexpr>T   s$      <<v6?<<<<<<r$   )setr   r   s    r#   r   zSourceSelector.catsQ   s#     <<<<<<<<r$   c                    g }t          |          D ]e}|j                                        D ]I\  }}	 |                                d         dk    r|                    |           :# t
          $ r Y Fw xY wf|| _        dS )zSet sources from a list of cats	containercatalogN)r   _entriesr   describeappendIOError)r   r   r    catkentrys         r#   r   zSourceSelector.catsV   s     !$'' 	 	CL..00  5~~''4	A .u---   D	 


s   3A''
A43A4c                 L    | j         r|                      |j                   d S d S r4   )r   new)r   events     r#   r-   zSourceSelector.callbackd   s3     	*uy)))))	* 	*r$   c                       j          j        d  j        D              fd j                                        D             dS )z)Serialize the current state of the objectc                 6    g | ]}|                                 S r   )__getstate__r6   s     r#   
<listcomp>z/SourceSelector.__getstate__.<locals>.<listcomp>m   s$    GGG&++--GGGr$   c                 ,    g | ]\  }}|j         v |S r   )selected)r7   rD   vr   s      r#   rL   z/SourceSelector.__getstate__.<locals>.<listcomp>n   s)    RRRtq!qDM?QRRRRr$   )visiblelabelsr    rN   )rP   rQ   r   optionsr;   s   `r#   rK   zSourceSelector.__getstate__h   sV     |kGGDJGGGRRRRt|'9'9';';RRR	
 
 	
r$   c                     |d         }|d         }d t          ||          D             | j        _        |                    dg           | _        |                    dd          | _        | S )zSet the current state of the object from the serialized version.
        Works inplace. See ``__getstate__`` to get serialized version and
        ``from_state`` to create a new object.r    rQ   c                 4    i | ]\  }}|t          |          S r   r   )r7   r0   r8   s      r#   
<dictcomp>z/SourceSelector.__setstate__.<locals>.<dictcomp>w   s&    hhh-%uof&=&=hhhr$   rN   rP   T)zipr   rR   getrN   rP   )r   stater    rQ   s       r#   __setstate__zSourceSelector.__setstate__q   sk     	"xhhSVW]_fSgSghhh		*b11yyD11r$   )NNN)__name__
__module____qualname____doc__
preprocessr/   r   r1   propertyr   setterr-   rK   rY   __classcell__)r"   s   @r#   r	   r	      s        $ $L JH     "- - - = = X= 
[  [* * *
 
 
	 	 	 	 	 	 	r$   r	   )r   r   intake.utilsr   baser   r   r	   r   r$   r#   <module>rd      s{        ( ( ( ( ( ( / / / / / / / /k k k k k\ k k k k kr$   