
    ,h                     :   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$y)    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                 n    t        |       }|j                         st        |      |j                         S )N)r   existsFileNotFoundErrorresolve)r   paths     P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/watchfiles/cli.pyresolve_pathr      s+    >D;;=%%||~    args_c                  2	   | xs t         j                  dd }t        j                  dt	        t
        j                  xs dj                  d            t        j                        }|j                  dd	       |j                  d
ddd       |j                  ddt        d       |j                  ddt        dg dd       |j                  ddt        dd       |j                  ddt        d       |j                  ddd !       |j                  d"dd#!       |j                  d$dt        d%g d&d'       |j                  d(dt        d)d*       |j                  d+dt        d,d-       |j                  d.dt        dd/       |j                  d0dd1!       |j                  d2d3d4d5t         6       |j                  |      }|j                  rt         j"                  }n(t%        t         |j&                  j)                               }t!        j*                         }|j-                  |       |j/                  t!        j0                  d7d89             t!        j2                  d      }|j5                  |       |j-                  |       |j6                  dk(  rt9        |j:                        }n|j6                  }|d:k(  rxt<        j?                  d;|j:                         tA        |j:                         |jB                  rX|j:                  gtE        jF                  |jB                        z   t         _        n!|jB                  rt<        jI                  d<       	 |jJ                  D cg c]  }tM        |       }	}tW        |jX                  |jZ                        \  }}t<        j]                  d@t        dAj_                  dB 	D              |j:                  ||       ta        |	|j:                  |||t         j"                  k(  |jb                  |jd                  |jf                   |jh                  |jj                  dC	 yc c}w # tN        $ r?}
tQ        d=|
 d>t         jR                  ?       t        jT                  d       Y d}
~
d}
~
ww xY w)Da  
    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 functionzpath "z" does not existfileu:   watchfiles v%s 👀  path=%s target="%s" (%s) filter=%s...z, c              3   (   K   | ]
  }d | d   yw)"N ).0ps     r   	<genexpr>zcli.<locals>.<genexpr>   s     *qAaS(*s   )	r'   target_typewatch_filterr8   sigint_timeoutsigkill_timeout	recursiveignore_permission_deniedgrace_period)6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
addHandlerrE   r   r'   loggerr8   import_exitargsshlexsplitr7   r)   r   r   printstderrexitbuild_filterfilterignore_pathsr6   joinr   rG   rH   non_recursiverJ   rK   )r   rg   parserarg_namespace	log_levelhdlr	wg_loggerrE   rC   r)   erF   watch_filter_strs                r   rP   rP      s]     CHHQRLD$$CKK-244T:; 55F
 'OP
sC.h   b   /U  
 _  
 q	   L?rs
,5n   ,,   N   Z   [   $T  
 T)zRYQZE[\%%d+MMM	G]%<%<%B%B%DE	  "DMM)g'',GQ[\]!!,/Iy!  F*()=)=>#//j FH\H\]M(()%,,-M<N<N0OOCH			JK*7*=*=>Qa>>
 &2-2F2FHbHb%c"L"
KKD		*E** 	##!7==($33%55#111!.!G!G"//! ? qc)*<s*   $Q 2Q	Q 	Q 	R4RRfunction_pathc                 6   t        j                         }|t        j                  vrt        j                  j	                  |       	 t        |       S # t        $ r=}t        d| t        j                         t        j                  d       Y d }~y d }~ww xY w)NzImportError: r=   r   )
osgetcwdrL   r   appendr   ImportErrorrj   rk   rl   )ry   cwdrw   s      r   rf   rf      sk    
))+C
#((]++ aS!

3s   
A 	B3BBfilter_nameignore_paths_strc                 x   g }|r5|j                  d      D cg c]  }t        |      j                          }}| dk(  rt        |      dfS | dk(  rt	        |      dfS | dk(  r|rt
        j                  d       y	t        |       }t        |t              r%t        |t              r ||      |j                  fS |rt
        j                  d
       t        |t              r#t        |t              r |       |j                  fS t        t        t        t         gt"        f   |      }|t%        |      fS c c}w )N,r-   )ro   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)ri   r   r   r   r   re   r7   rf   
isinstancer/   
issubclass__name__r   r   r   r   rU   boolrepr)r   r   ro   rC   watch_filter_clsrF   s         r   rm   rm      s#     "L3C3I3I#3NOaQ)OOi,7HH		 6FF		NN[\"";/"D)j9I=.Y\:<L<U<UUUgh"D)j9I:.V!#3#<#<<<Hfc]D%89;KLT"2333- Ps    D7)%rN   rZ   r{   rh   rL   pathlibr   textwrapr   typingr   r   r   r   r	   r
   r   r"   r   filtersr   r   r   runr   r   r   r:   r   rc   re   rU   r   rP   rf   r   rm   rA   r   r   <module>r      s      	  
   D D D  < < ? ? 			+	,3 4 \ \ \~	s 	s 	44(04
5}h}d/B&CCDcIJ4r   