o
    Zh                     @  s   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 dZeed ee ee f Z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d.d%d&ZdS )/    )annotationsN)CallableUnion)cli_utilconfigenv_util)PollingPathWatcherc                   @  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/Persson_Maskin/env/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   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_available7   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_availabilityA   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-   r.   r   r   watcher_classr   r   r   _watch_pathT   s   "
r1   on_file_changedc                 C  s   t | ||S r   )r1   )r,   r2   r.   r   r   r   
watch_file   s   r3   on_dir_changedc                C  s    t j| d} t| ||||dS )Nr#   r
   )osr,   joinr1   )r,   r4   r.   r   r   r   r   r   	watch_dir   s   
r7   PathWatcherTypec                   C  s   t tdS )zsReturn the class to use for path changes notifications, based on the
    server.fileWatcherType config option.
    r    )r/   r   r'   r   r   r   r   get_default_path_watcher_class   s   r9   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	   )r.   r;   r   r   r   r/      s   r/   )r   r   )r   r   r   )r,   r   r-   r   r.   r   r   r   r   r   r   r   )r,   r   r2   r   r.   r   r   r   )r,   r   r4   r   r.   r   r   r   r   r   r   r   )r   r8   )r.   r   r   r8   )
__future__r   r5   typingr   r   streamlit.watcher	streamlitr   r   r   &streamlit.watcher.polling_path_watcherr   r	   typer8   r   r+   r1   r3   r7   r9   r/   r   r   r   r   <module>   s:   


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