
    +d                     :    d dl Z ddlmZmZ  G d de          ZdS )    N   )DictSerialiseMixinpretty_describec                       e Zd ZdZddZd Zd ZddZed             Z	e	j
        d	             Z	ed
             Zed             Zd Zd Zd Zd Zd Zed             ZdS )CatalogEntryzA single item appearing in a catalog

    This is the base class, used by local entries (i.e., read from a YAML file)
    and by remote entries (read from a server).
    Tc                 >    d | _         || _        || _        d| _        d S )Ndefault)_default_sourcegetenvgetshell_pmode)selfr   r   s      4lib/python3.11/site-packages/intake/catalog/entry.py__init__zCatalogEntry.__init__   s#    #     c                     t           )a  Get a dictionary of attributes of this entry.

        Returns: dict with keys
          name: str
              The name of the catalog entry.
          container : str
              kind of container used by this data source
          description : str
              Markdown-friendly description of data source
          direct_access : str
              Mode of remote access: forbid, allow, force
          user_parameters : list[dict]
              List of user parameters defined by this entry

        NotImplementedErrorr   s    r   describezCatalogEntry.describe   s
      "!r   c                     t           )a  Open the data source.

        Equivalent to calling the catalog entry like a function.

        Note: ``entry()``, ``entry.attr``, ``entry[item]`` check for persisted
        sources, but directly calling ``.get()`` will always ignore the
        persisted store (equivalent to ``self._pmode=='never'``).

        Parameters
        ----------
          user_parameters : dict
              Values for user-configurable parameters for this data source

        Returns
        -------
        DataSource
        r   )r   user_parameterss     r   getzCatalogEntry.get,   s
    $ "!r   Nc                    ddl m} ||dvrt          d|z            |p| j        } | j        di |}|dk    rt          ||          rw|j        rpddlm} |	                                }|j
        }|dk    s|d	         s|}n>|d	         t          j                    |d
         z
  k     r|}n|                    |          }| |_        t          |          |_        |S )aa  Instantiate DataSource with given user arguments

        Parameters
        ----------
        persist: str or None
            Override persistence mode defined in the parent catalog. If not
            None, must be one of ['always', 'never', 'default']. Has no
            effect if the source has never been persisted, use source.persist()
        r   )PersistMixinN)alwaysneverr	   z!Persist value (%s) not understoodr   )storer   ttl	timestamp )source.baser   
ValueErrorr   r   
isinstancehas_been_persistedcontainer.persistr   get_persistedmetadatatimerefresh_entrylist_passed_kwargs)r   persistkwargsr   sr   s2mets           r   __call__zCatalogEntry.__call__@   s&    	/..... 	L72P#P 	L@7JKKK(T[DHvg 
	&*Q"="= 
	&!BV 
	&111111""B+C(" &#e* &UdikkC,<<< &MM"%%<<r   c                 $    t          | dd           S )N
_container)getattrr   s    r   	containerzCatalogEntry.container_   s    t\4000r   c                     || _         d S N)r5   )r   conts     r   r7   zCatalogEntry.containerc   s     r   c                 &     | j         di |j        S )zBFor the source created with the given args, has it been persisted?r!   )r   r%   )r   r/   s     r   r%   zCatalogEntry.has_been_persistedi   s     tx!!&!!44r   c                 R    t          | j                            di                     S )z"List custom associated quick-plotsplots)r,   	_metadatar   r   s    r   r=   zCatalogEntry.plotsn   s$     DN&&w33444r   c                     ddl }ddlm} |                                 } ||                    |          t          |          ddd|d         iid	           dS )
z9Display the entry as a rich object in an IPython session.r   N)display)application/jsonz
text/plainrA   rootnameT)r(   raw)jsonIPython.displayr@   r   dumpsr   )r   rE   r@   contentss       r   _ipython_display_zCatalogEntry._ipython_display_s   s    ++++++==??!%H!5!5_U]E^E^__k}  AG  IQ  RX  IY  @Z  k[  ae	
 	
 	
 	
 	
 	
r   c                 <    d| j         |                                 iiS )Nsources)rC   r   r   s    r   _yamlzCatalogEntry._yaml~   s    DIt}}788r   c                 d    | j         dk    rt           |                       S t          d          )NcatalogzCannot iterate a catalog entry)r5   iterr#   r   s    r   __iter__zCatalogEntry.__iter__   s2    ?i' 	?<<=>>>r   c                     t          |t                    rLt          |          dk    r1 |             |d                                      |dd                   S |d         } |             |         S )zPass getitem to data source, assuming default parameters

        Also supports multiple items ([.., ..]), in which case the first
        component only will be used to instantiate, and the rest passed on.
           r   N)r$   tuplelen__getitem__)r   items     r   rU   zCatalogEntry.__getitem__   sk     dE"" 	4yy1} tvvd1g2248<<<Awtvvd|r   c                 D    t          |                                           S r9   )r   r   r   s    r   __repr__zCatalogEntry.__repr__   s    t}}///r   c                 z    t          | d          sddlm}  || d          | _        nd| j        _        | j        S )N_guirR   )EntryGUIT)sourcevisible)hasattrguir[   rZ   r]   )r   r[   s     r   r_   zCatalogEntry.gui   sP    tV$$ 	%%%%%%% d;;;DII $DIyr   )TTr9   )__name__
__module____qualname____doc__r   r   r   r3   propertyr7   setterr%   r=   rI   rL   rP   rU   rX   r_   r!   r   r   r   r      s:               " " "$" " "(   > 1 1 X1   
 5 5 X5 5 5 X5	
 	
 	
9 9 9? ? ?  0 0 0   X  r   r   )r)   utilsr   r   r   r!   r   r   <module>rg      sg     7 7 7 7 7 7 7 7S S S S S% S S S S Sr   