
    2'&h                     P   d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZmZmZ ddlmZmZmZ dd	lmZ  ej        d
          ZdedefdZ deddfdZ!dede
fdZ"dedee         deedeeeege#f         f         ef         fdZ$dS )    N)Path)dedent)AnyCallableListOptionalTupleUnioncast   )Change)
BaseFilterDefaultFilterPythonFilter)detect_target_typeimport_stringrun_process)VERSIONzwatchfiles.clipath_strreturnc                     t          |           }|                                st          |          |                                S )N)r   existsFileNotFoundErrorresolve)r   paths     I/var/www/html/reinick/venv/lib/python3.11/site-packages/watchfiles/cli.pyresolve_pathr      s9    >>D;;== %%%||~~    args_c                  ,	   | pt           j        dd         }t          j        dt	          t
          j        pd                    d                    t          j                  }|	                    dd	           |	                    d
ddd           |	                    ddt          d           |	                    ddt          dg dd           |	                    ddt          dd           |	                    ddt          d           |	                    ddd !           |	                    d"dd#!           |	                    d$dt          d%g d&d'           |	                    d(dt          d)d*           |	                    d+dt          d,d-           |	                    d.dt          dd/           |	                    d0dd1!           |	                    d2d3d4d5t           6           |                    |          }|j        rt           j        }n,t%          t           |j                                                  }t!          j                    }|                    |           |                    t!          j        d7d89                     t!          j        d          }|                    |           |                    |           |j        dk    rt9          |j                  }n|j        }|d:k    rht<                              d;|j                   tA          |j                   |j!        r,|j        gtE          j#        |j!                  z   t           _        n!|j!        rt<          $                    d<           	 d= |j%        D             }nJ# tL          $ r=}	tO          d>|	 d?t           j(        @           t          j)        d           Y d}	~	nd}	~	ww xY wtU          |j+        |j,                  \  }
}t<          -                    dAt          dB.                    dC |D                       |j        ||           t_          ||j        ||
|t           j        k    |j0        |j1        |j2         |j3        |j4        dD	 dS )Ea  
    Watch one or more directories and execute either a shell command or a python function on file changes.

    Example of watching the current directory and calling a python function:

        watchfiles foobar.main

    Example of watching python files in two local directories and calling a shell command:

        watchfiles --filter python 'pytest --lf' src tests

    See https://watchfiles.helpmanual.io/cli/ for more information.
    r   N
watchfiles 
)progdescriptionformatter_classtargetz&Command or dotted function path to run)helppaths*.z8Filesystem paths to watch, defaults to current directory)nargsdefaultr(   z--ignore-paths?zrSpecify directories to ignore, to ignore multiple paths use a comma as separator, e.g. "env" or "env,node_modules")r,   typer(   z--target-typeauto)commandfunctionr0   zWhether the target should be intercepted as a shell command or a python function, defaults to "auto" which infers the target type from the target string)r,   r/   r-   choicesr(   z--filterr-   zWhich files to watch, defaults to "default" which uses the "DefaultFilter", "python" uses the "PythonFilter", "all" uses no filter, any other value is interpreted as a python function/class path which is imported)r,   r/   r-   r(   z--argszbArguments to set on sys.argv before calling target function, used only if the target is a functionz	--verbose
store_truez1Set log level to "debug", wins over `--verbosity`)actionr(   z--non-recursivez7Do not watch for changes in sub-directories recursivelyz--verbosityinfo)warningr6   debugzLog level, defaults to "info"z--sigint-timeout   z?How long to wait for the sigint timeout before sending sigkill.z--grace-periodr   zKNumber of seconds after the process is started before watching for changes.z--sigkill-timeoutzLHow long to wait for the sigkill timeout before issuing a timeout exception.z--ignore-permission-deniedzEIgnore permission denied errors while watching files and directories.z	--versionz-Vversionz
%(prog)s v)r5   r:   z[%(asctime)s] %(message)sz%H:%M:%S)fmtdatefmtr2   z/target_type=function, attempting import of "%s"z1--args is only used when the target is a functionc                 ,    g | ]}t          |          S  )r   .0ps     r   
<listcomp>zcli.<locals>.<listcomp>   s    >>>Qa>>>r   zpath "z" does not existfileu:   watchfiles v%s 👀  path=%s target="%s" (%s) filter=%s...z, c              3   "   K   | ]
}d | d V  dS )"Nr>   r?   s     r   	<genexpr>zcli.<locals>.<genexpr>   s*      **q(a(((******r   )	r'   target_typewatch_filterr8   sigint_timeoutsigkill_timeout	recursiveignore_permission_deniedgrace_period)5sysargvargparseArgumentParserr   cli__doc__stripRawTextHelpFormatteradd_argumentstrintfloatr   
parse_argsverboseloggingDEBUGgetattr	verbosityupperStreamHandlersetLevelsetFormatter	Formatter	getLogger
addHandlerrH   r   r'   loggerr8   import_exitargsshlexsplitr7   r)   r   printstderrexitbuild_filterfilterignore_pathsr6   joinr   rJ   rK   non_recursiverM   rN   )r   rj   parserarg_namespace	log_levelhdlr	wg_loggerrH   r)   erI   watch_filter_strs               r   rS   rS      sS     CHQRRLD$CK-244T::;; 5  F
 'OPPP
sC.h     b     ///U  
 
 
 _  
 
 
 q	     L?rsss
,5n     ,,,,     N     Z     [     $T    
 T)E[RYE[E[\\\%%d++M FM		G]%<%B%B%D%DEE	 ""DMM)g',GQ[\\\]]]!,//Iy!!! F**()=>>#/j  FH\]]]M())) 	P%,-M<N0O0OOCH		 LJKKK>>-*=>>>   *q***<<<< &2-2FHb%c%c"L"
KKD		**E*****   	#!7=($3%5#11!.!G"/     s   N& &
O-03O((O-function_pathc                 6   t          j                    }|t          j        vrt          j                            |           	 t          |           S # t          $ r=}t          d| t          j                   t          j	        d           Y d }~d S d }~ww xY w)NzImportError: rC   r   )
osgetcwdrO   r   appendr   ImportErrorrm   rn   ro   )r|   cwdrz   s      r   ri   ri      s    
)++C
#(]+++   !a!!
3333s   A 
B2BBfilter_nameignore_paths_strc                    g }|rd |                     d          D             }| dk    rt          |          dfS | dk    rt          |          dfS | dk    r|rt                              d	           d
S t          |           }t          |t                    r(t          |t                    r ||          |j	        fS |rt                              d           t          |t                    r&t          |t                    r |            |j	        fS t          t          t          t          gt          f         |          }|t!          |          fS )Nc                 P    g | ]#}t          |                                          $S r>   )r   r   r?   s     r   rB   z build_filter.<locals>.<listcomp>   s(    OOOaQ))OOOr   ,r-   )rr   r   pythonr   allz>"--ignore-paths" argument ignored as "all" filter was selected)Nz(no filter)zN"--ignore-paths" argument ignored as filter is not a subclass of DefaultFilter)rl   r   r   rh   r7   ri   
isinstancer/   
issubclass__name__r   r   r   r   rX   boolrepr)r   r   rr   watch_filter_clsrI   s        r   rp   rp      s     "L POO3C3I3I#3N3NOOOi,777HH		 	 666FF			 	]NN[\\\""";//"D)) Vj9I=.Y.Y V\:::<L<UUU ighhh"D)) 4j9I:.V.V 4!!#3#<<<Hfc]D%89;KLLT"23333r   )%rQ   r]   r~   rk   rO   pathlibr   textwrapr   typingr   r   r   r   r	   r
   r   r"   r   filtersr   r   r   runr   r   r   r:   r   rf   rh   rX   r   rS   ri   r   rp   r>   r   r   <module>r      s     				  



             D D D D D D D D D D D D D D D D D D       < < < < < < < < < < ? ? ? ? ? ? ? ? ? ?      		+	,	,3 4    \ \ \ \ \ \~	s 	s 	 	 	 	44(04
5}h}d/B&CCDcIJ4 4 4 4 4 4r   