
    &e.                        d dl mZmZmZmZ d dlZd dlZd dlmZm	Z	 d dl
mZ d dlmZ  ee          Z	 d dlmZ dZn# e$ r dZ G d	 d
          ZY nw xY w G d d          Zeed         ee         ee         f         Zd Z	 dddddedeegdf         dee         dee         dedefdZ	 ddedeegdf         dee         defdZ	 dddddedeegdf         dee         dee         dedefdZdefdZdedefdZdS )    )CallableOptionalTypeUnionN)configenv_util)
get_logger)PollingPathWatcher)EventBasedPathWatcherTFc                       e Zd ZdS )r   N)__name__
__module____qualname__     >lib/python3.11/site-packages/streamlit/watcher/path_watcher.pyr   r   #   s        r   r   c            	       L    e Zd Zddddedeegdf         dee         defdZdS )	NoOpPathWatcherNFglob_patternallow_nonexistent	_path_str_on_changedr   r   c                    d S Nr   )selfr   r   r   r   s        r   __init__zNoOpPathWatcher.__init__0   s	     	r   )r   r   r   strr   r   boolr   r   r   r   r   r   /   so         '+"'   seTk*
 sm       r   r   z@streamlit.watcher.event_based_path_watcher.EventBasedPathWatcherc                      t           sWt          j        d          sEt          j        rdnd} t          j        ddz  dd           t          j        d	| z             d S d S d S )
Nzglobal.disableWatchdogWarningz
  $ xcode-select --install z  %sz4For better performance, install the Watchdog module:blueT)fgboldz(%s
  $ pip install watchdog
            )watchdog_availabler   
get_optionr   	IS_DARWINclicksecho)msgs    r   report_watchdog_availabilityr+   E   s      !@AA 	4<4FN00BCKOO   
 K      	 	r   r   pathon_path_changedwatcher_typer   r   returnc                    |t          j        d          }t          |          }|t          u rdS  || |||           dS )a&  Create a PathWatcher for the given path if we have a viable
    PathWatcher class.

    Parameters
    ----------
    path
        Path to watch.
    on_path_changed
        Function that's called when the path changes.
    watcher_type
        Optional watcher_type string. If None, it will default to the
        'server.fileWatcherType` config option.
    glob_pattern
        Optional glob pattern to use when watching a directory. If set, only
        files matching the pattern will be counted as being created/deleted
        within the watched directory.
    allow_nonexistent
        If True, allow the file or directory at the given path to be
        nonexistent.

    Returns
    -------
    bool
        True if the path is being watched, or False if we have no
        PathWatcher class.
    Nserver.fileWatcherTypeFr   T)r   r&   get_path_watcher_classr   )r,   r-   r.   r   r   watcher_classs         r   _watch_pathr4   W   se    D ()ABB*<88M''uM!+	    4r   on_file_changedc                 $    t          | ||          S r   r4   )r,   r5   r.   s      r   
watch_filer8      s    
 t_l;;;r   on_dir_changedc                *    t          | ||||          S )Nr   r7   )r,   r9   r.   r   r   s        r   	watch_dirr;      s*     !+   r   c                  D    t          t          j        d                    S )zsReturn the class to use for path changes notifications, based on the
    server.fileWatcherType config option.
    r1   )r2   r   r&   r   r   r   get_default_path_watcher_classr=      s     "&"34L"M"MNNNr   c                     | dk    rt           rt          S t          S | dk    rt           rt          S | dk    rt          S t          S )zReturn the PathWatcher class that corresponds to the given watcher_type
    string. Acceptable values are 'auto', 'watchdog', 'poll' and 'none'.
    autowatchdogpoll)r%   r   r
   r   )r.   s    r   r2   r2      sQ     v 	&((%%		#	#(:	#$$			!!r   r   )typingr   r   r   r   r(   streamlit.watcher	streamlitr   r   streamlit.loggerr	   &streamlit.watcher.polling_path_watcherr
   r   LOGGER*streamlit.watcher.event_based_path_watcherr   r%   ImportErrorr   PathWatcherTyper+   r   r   r4   r8   r;   r=   r2   r   r   r   <module>rK      s   3 2 2 2 2 2 2 2 2 2 2 2      & & & & & & & & ' ' ' ' ' ' E E E E E E	H		
PPPPPP            	 	 	 	 	 	 	 	 	 	KL	  * #'/
 #'#/ / /
/seTk*/ 3-/
 3-/ / 
/ / / /j #'< <
<seTk*< 3-< 
	< < < < #'
 #'#  
cUD[) 3-
 3-  
   "O O O O O       s   > AA