
    gV                       d dl mZ d dlZd dlmZmZ d dlZd dlmZm	Z	m
Z
 d dlmZ  G d d      Zeed   ee   ee   f   Zdd	Zd
 Z	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZ	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZddZddZy)    )annotationsN)CallableUnion)cli_utilconfigenv_util)PollingPathWatcherc                  *    e Zd Zddd	 	 	 	 	 	 	 ddZy)NoOpPathWatcherNFglob_patternallow_nonexistentc                    y N )self	_path_str_on_changedr   r   s        S/var/www/openai/venv/lib/python3.12/site-packages/streamlit/watcher/path_watcher.py__init__zNoOpPathWatcher.__init__"   s     	    )r   strr   Callable[[str], None]r   
str | Noner   bool)__name__
__module____qualname__r   r   r   r   r   r   !   s5     $("' +
 !  r   r   z@streamlit.watcher.event_based_path_watcher.EventBasedPathWatcherc                 ,    	 ddl } y# t        $ r Y yw xY w)z*Check if the watchdog module is installed.r   NTF)watchdogImportError)r    s    r   _is_watchdog_availabler"   7   s     s    	c                     t        j                  d      dvrSt               sHt        j                  rdnd} t        j                  ddz  dd	       t        j                  d
| z         y y y )Nserver.fileWatcherType)pollnonez
  $ xcode-select --install z  %sz4For better performance, install the Watchdog module:blueT)fgboldz(%s
  $ pip install watchdog
            )r   
get_optionr"   r   	IS_DARWINr   print_to_cli)msgs    r   report_watchdog_availabilityr/   A   st    23;KK&(080B0B,KK	

 	 	
 ) 	Lr   Fr   c               r    |t        j                  d      }t        |      }|t        u ry || |||       y)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.
    r$   Fr   T)r   r+   get_path_watcher_classr   )pathon_path_changedwatcher_typer   r   watcher_classs         r   _watch_pathr6   U   sJ    D (()AB*<8M'!+	 r   c                    t        | ||      S r   )r6   )r2   on_file_changedr4   s      r   
watch_filer9      s    
 t_l;;r   c               b    t         j                  j                  | d      } t        | ||||      S )Nr'   r   )osr2   joinr6   )r2   on_dir_changedr4   r   r   s        r   	watch_dirr>      s4     77<<b!D!+ r   c                 >    t        t        j                  d            S )zsReturn the class to use for path changes notifications, based on the
    server.fileWatcherType config option.
    r$   )r1   r   r+   r   r   r   get_default_path_watcher_classr@      s     "&"3"34L"MNNr   c                f    | dv rt               rddlm} |S | dk(  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'.
    >   autor    r   )EventBasedPathWatcherrB   r%   )r"   *streamlit.watcher.event_based_path_watcherrC   r	   r   )r4   rC   s     r   r1   r1      s>     ++0F0HT$$		!!		!!r   )returnr   r   )r2   r   r3   r   r4   r   r   r   r   r   rE   r   )r2   r   r8   r   r4   r   rE   r   )r2   r   r=   r   r4   r   r   r   r   r   rE   r   )rE   PathWatcherType)r4   r   rE   rF   )
__future__r   r;   typingr   r   streamlit.watcher	streamlitr   r   r   &streamlit.watcher.polling_path_watcherr	   r   typerF   r"   r/   r6   r9   r>   r@   r1   r   r   r   <module>rM      s3   # 	 "  0 0 E	 	 	KL	
.  $/
  $#/
/*/ /
 / / 
/j  $<
<*< < 
	<  $
  $#
) 
   
*Or   