o
    ,&]iT                     @  s   U 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 er/d dlmZ G dd dZed	 ee B ee B Zd
ed< d)ddZd*ddZ	d+dddd,ddZ	d+d-d d!Z	d+dddd.d#d$Zd/d%d&Zd0d'd(ZdS )1    )annotationsN)TYPE_CHECKING	TypeAlias)cli_utilconfigenv_util)PollingPathWatcher)Callablec                   @  s   e Zd ZddddddZdS )NoOpPathWatcherNFglob_patternallow_nonexistent	_path_strstr_on_changedCallable[[str], None]r   
str | Noner   boolreturnNonec                C  s   d S N )selfr   r   r   r   r   r   \/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/watcher/path_watcher.py__init__%   s   zNoOpPathWatcher.__init__)
r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r
   $   s    r
   z@streamlit.watcher.event_based_path_watcher.EventBasedPathWatcherr   PathWatcherTyper   r   c                  C  s$   zddl } W dS  ty   Y dS w )z*Check if the watchdog module is installed.r   NTF)watchdogImportError)r   r   r   r   _is_watchdog_available:   s   r!   r   c                  C  sN   t ddvr#t s%tjrdnd} tjdddd t|  d	 d S d S d S )
Nserver.fileWatcherType)pollnonez
  $ xcode-select --install z6  For better performance, install the Watchdog module:blueT)fgboldz&
  $ pip install watchdog
            )r   
get_optionr!   r   	IS_DARWINr   print_to_cli)msgr   r   r   report_watchdog_availabilityD   s   r-   Fr   pathr   on_path_changedr   watcher_typer   r   r   c                C  s:   |du r	t d}t|}|tu rdS || |||d 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.
    Nr"   Fr   T)r   r)   get_path_watcher_classr
   )r.   r/   r0   r   r   watcher_classr   r   r   _watch_pathW   s   "
r3   on_file_changedc                 C  s   t | ||S r   )r3   )r.   r4   r0   r   r   r   
watch_file   s   r5   on_dir_changedc                C  s    t j| d} t| ||||dS )Nr%   r   )osr.   joinr3   )r.   r6   r0   r   r   r   r   r   	watch_dir   s   
r9   c                   C  s   t t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   r   get_default_path_watcher_class   s   r:   c                 C  s.   | dv rt  rddlm} |S | dv 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   )EventBasedPathWatcher>   r;   r#   )r!   *streamlit.watcher.event_based_path_watcherr<   r   r
   )r0   r<   r   r   r   r1      s   r1   )r   r   )r   r   r   )r.   r   r/   r   r0   r   r   r   r   r   r   r   )r.   r   r4   r   r0   r   r   r   )r.   r   r6   r   r0   r   r   r   r   r   r   r   )r   r   )r0   r   r   r   )
__future__r   r7   typingr   r   streamlit.watcher	streamlitr   r   r   &streamlit.watcher.polling_path_watcherr   collections.abcr	   r
   typer   __annotations__r!   r-   r3   r5   r9   r:   r1   r   r   r   r   <module>   s>   



5
