Files
intellecton/venv/lib/python3.12/site-packages/watchdog/__pycache__/watchmedo.cpython-312.pyc
T

243 lines
26 KiB
Plaintext
Raw Normal View History

Ë
jlcãóºdZddlmZddlZddlZddlZddlZddlZddlZddl m
Z
m Z ddl m
Z
ddlmZddlmZmZddlmZmZmZdd lmZer dd
l mZmZdd lmZdd lmZdd
lmZddl m!Z!ejDejF¬«dZ$dZ%Gdde «Z&dZ'e
e'e&¬«Z(e(jSdde¬«e(jUd¬«Z+iZ,e-e.e/efZ0ddZ1e+ddœ dždZ2ejfdœdŸdZ4dd œd d!„Z5d¡d"„Z6d#dœ d¢d$„Z7 d£d&„Z8d¤d'„Z9e2e1d(d)d*¬+«e1d,d-d.ejfd/¬0«e1d1d2d3d4e:d5¬6«e1d7d8d9d:¬;«e1d<d8d=¬>«e1d?d8d@¬>«e1dAd8dB¬>«e1dCd8dD¬>«e1dEd8dF¬>«g dg¬G«d¥dH„«Z;e2e1dId)dJ¬+«e1d,d-d.ejfd/¬0«e1dKddL¬0«e1dMdNdOd8dP¬Q«gdRg¬G«d¥dS„«Z<e2e1dTd)d-dU¬V«e1dWdXdYdZd)d[¬\«e1d]d^d_d`dadb¬\«e1dcddded8df¬Q«e1dgd7d%d8dh¬Q«e1d1d2d3d4e:di¬6«e1d<d8d=¬>«e1d?d8d@¬>«e1dAd8dB¬>«e1dCd8dD¬>«e1dEd8dF¬>«g «d¥dj„«Z=e2e1dTd)d-dk¬V«e1dldmdnddo¬\«e1dWdXdYdZd)d[¬\«e1d]d^d_d`dadb¬\«e1dcdddedpd8df¬q«e1dgd7d%d8dh¬Q«e1d1d2d3d4e:di¬6«e1drdsdtd8du¬Q«e1dvdwdxd8dy¬Q«e1d<d8d=¬>«g
«d¥dz„«Z>e2e1dnd{¬|«e1d}d~d)d¬€«e1dddTdƒd„d…¬†«e1dWdXdYdZd)d[¬\«e1d]d^d_d`dadb¬\«e1dcdddedpd8df¬q«e1dgd7d%d8dh¬Q«e1d1d2d3d4e:di¬6«e1d‡dˆd‰dЬ\«e1d<d8d=¬>«e1ddŒde:dެ6«e1ddde:d’¬6«e1d“d”d9d•d–¬q«g
«d¥d—„«Z?Gd˜„d™e@«ZAd¦dš„ZBd§d›„ZCeDdœk(reeC««yy)¨u´:module: watchdog.watchmedo
:author: yesudeep@google.com (Yesudeep Mangalapilly)
:author: contact@tiger-222.fr (Mickaël Schoentgen)
:synopsis: ``watchmedo`` shell script utility.
é)Ú annotationsN)ÚArgumentParserÚRawDescriptionHelpFormatter)ÚStringIO)Údedent)Ú
TYPE_CHECKINGÚAny)ÚWatchdogShutdownErrorÚ
load_classÚplatform)ÚVERSION_STRING)Ú NamespaceÚ_SubParsersAction)ÚCallable)ÚFileSystemEventHandler)Ú ObserverType)Ú BaseObserver)ÚlevelÚtricksz python-pathcó:eZdZdZddœdˆfdZddZd dZˆxZS)
Ú
HelpFormattera#A nicer help formatter.
Help for arguments can be indented and contain new lines.
It will be de-dented and arguments in the help
will be separated by a blank line for better readability.
Source: https://github.com/httpie/httpie/blob/2423f89/httpie/cli/argparser.py#L31
é)Úmax_help_positioncó.||d<t||i|¤Žy)Nr)ÚsuperÚ__init__)ÚselfrÚargsÚkwargsÚ __class__s €úU/home/antigravity/intellecton/venv/lib/python3.12/site-packages/watchdog/watchmedo.pyrzHelpFormatter.__init__0s ø€à&7ˆÐ
ј) có4dt|«jdS)>)ÚtypeÚ__name__)rs r!Ú__repr__zHelpFormatter.__repr__5sØ”4˜“:×' )r"cóZt|«j«dz}|j«S)Nz
)rÚstripÚ
splitlines)rÚtextÚwidths r!Ú _split_lineszHelpFormatter._split_lines8s&Üd|×# fÑ,ˆØÓ Ð r")rr rÚintrr ÚreturnÚNone)r0Ústr)r,r2r-r/r0ú list[str])r'Ú
__module__Ú __qualname__Ú__doc__rr(r.Ú
__classcell__)r s@r!rr&sø„ñð=>÷
!r"ru,Copyright 2018-2024 Mickaël Schoentgen & contributors
Copyright 2014-2018 Thomas Amland & contributors
Copyright 2012-2014 Google, Inc.
Copyright 2011-2012 Yesudeep Mangalapilly
Licensed under the terms of the Apache license, version 2.0. Please see
LICENSE in the source code for more information.)ÚepilogÚformatter_classz --versionÚversion)Úactionr:Ú top_command)Údestcót|«|fS)z\Convenience function to properly format arguments to pass to the
command decorator.
)Úlist)Ú
name_or_flagsrs r!ÚargumentrANsô 
Ó  Ð &r")ÚparentÚ cmd_aliasescódˆˆˆfd }|S)a
Decorator to define a new command in a sanity-preserving way.
The function will be stored in the ``func`` variable when the parser
parses arguments so that it can be called directly like so::
>>> args = cli.parse_args()
>>> args.func(args)
có’|jjdd«}t|jxsd«}‰ j |xsg|t
¬«}|t |<|j«}|jddddd ¬
«|jd d ddd
¬
«D])\}}|j|i|¤Ž|j|¬«Œ+|S))ÚaliasesÚ descriptionr9z-qz--quietÚ verbosityÚ append_constéÿÿÿÿ)r=r;Úconstz-vz --verboseé)Úfunc)
r'Úreplacerr6Ú
add_parserrÚcommand_parsersÚadd_mutually_exclusive_groupÚ add_argumentÚ set_defaults)
rPÚnameÚdescÚparserÚverbosity_groupr@rrrCrBs
€€€r!Ú decoratorzcommand.<locals>.decoratordø€Ø}‰}×$ S¨#ÓÜd—l( )ˆØ×" Ò1BÀÐPTÔfsÐtˆØ &Œ˜ÑØ ×Ø×$ T¨9¸;È~ÐegÐ×$ T¨;¸[ÐQ_ÐghÐiØ%)ò !ˆM˜6Ø ˆF× Ñ  Ð 9°&Ò × Ñ   Õ ˆ r")rPrr0r©)rrBrCr[s``` r!Úcommandr]Usú€÷ ð Ðr")Ú separatorcó$|j|«S)zêSplits a pathname specification separated by an OS-dependent separator.
:param pathname_spec:
The pathname specification.
:param separator:
(OS Dependent) `:` on Unix and `;` on Windows or user-specified.
©Úsplit)Ú
pathname_specr^s r!Ú
path_splitrctsð × Ñ ˜ )r")Úindexcó^|dddD]"}tjj||«Œ$y)zòAdds specified paths at specified index into the sys.path list.
:param paths:
A list of paths to add to the sys.path
:param index:
(Default 0) The index in the sys.path list where the paths will be
added.
NrM)ÚsysÚpathÚinsert)Ú pathnamesrdÚpathnames r!Úadd_to_sys_pathrks-ð™d ˜d‘OòÜ ˜˜)r"cóŒddl}t|d«5}|j|j««cddd«S#1swYyxYw)zÌLoads the YAML configuration from the specified file.
:param tricks_file_path:
The path to the tricks configuration file.
:returns:
A dictionary of configuration information.
rrb)ÚyamlÚopenÚ safe_loadÚread)Útricks_file_pathnamernÚfs r!Ú load_configrtŒs;óä
Ð" DÓ )ð(¨QØ~‰~˜aŸf™f(ús :ºAú;có^|j|«}|j|«}|dgk(rg}||fS)z^Parses pattern argument specs and returns a two-tuple of
(patterns, ignore_patterns).
rHr`)Ú
patterns_specÚignore_patterns_specr^ÚpatternsÚignore_patternss r!Úparse_patternsr{šs>ð ×" -€HØ*×Ó;€Oؘ2˜$ÒØˆØ  $r"Ú recursivecóút|«D]}|j|||¬«Œ|j« tjd«Œ#t
$r|j
«YnwxYw|j«y)agSingle observer thread with a scheduled path and event handler.
:param observer:
The observer thread.
:param event_handler:
Event handler which will be called in response to file system events.
:param pathnames:
A list of pathnames to monitor.
:param recursive:
``True`` if recursive; ``False`` otherwise.
©r|rON)ÚsetÚscheduleÚstartÚtimeÚsleepr
ÚstopÚjoin)ÚobserverÚ
event_handlerrir|rjs r!Ú observe_withrˆ§sqô$˜ “NòHˆØ×ј-¨¸YÐÕHà ‡NðØÜ J‰JqŒMðøä òØ
Žðúà ‡MM…OsA
Á
A)Á(A)có²|D]R}|j«D]=\}}t|«}|di|¤Ž}t|dd«xs|} |j|| |¬«Œ?ŒTy)ajSchedules tricks with the specified observer and for the given watch
path.
:param observer:
The observer thread into which to schedule the trick and watch.
:param tricks:
A list of tricks.
:param pathname:
A path name which should be watched.
:param recursive:
``True`` if recursive; ``False`` otherwise.
Úsource_directoryNr~r\)Úitemsr Úgetattrr€)
r†rrjr|ÚtrickrWÚvalueÚ trick_clsÚhandlerÚtrick_pathnames
r!Úschedule_tricksrÄspðòLˆØ Ÿ;™; L‰KˆD" (ˆÑ( (ˆ$ WÐ.@À$ÓSÈ8ˆNØ × Ñ ˜g ~ÀÐ Õ  LñLr"ÚfilesÚ*zperform tricks from given file)ÚnargsÚhelpz
--python-pathú.zPaths separated by z to add to the Python path.)Údefaultrz
--intervalz --timeoutÚtimeoutgð?z?Use this as the polling interval/blocking timeout (in seconds).)r=r˜r&rz --recursiveÚ
store_trueTz-Recursively monitor paths (defaults to True).)r;r˜rz--debug-force-pollingz[debug] Forces polling.)r;rz--debug-force-kqueuez[debug] Forces BSD kqueue(2).z--debug-force-winapizebug] Forces Windows API.z--debug-force-fseventsz[debug] Forces macOS FSEvents.z--debug-force-inotifyz [debug] Forces Linux inotify(7).)rCcóü|jr ddlm}|}n||jr ddlm}|}ngt s |jst rtj«r ddl
m }|}n2|jr ddl
m}|}n|jr ddlm}|}nddlm}|}t)t+|j,««g}|j.D],} ||j0¬«}
t2j4j7| «s<t9t:j<t3j>t:j<«| «tA| «} | tB} tF| vrt)| tF«t2j4jI| «xs1t2j4jKt3jL««}tO|
| ||jP¬
«|
jS«|jU|
«Œ/ tWjXd«Œ#tD$r}
d tBd
| d }tE|«|
d }
~
wwxYw#tZ$r*|D]"}|j]«|j_«Œ$YnwxYw|D]}|ja«Œy )z;Command to execute tricks from a tricks configuration file.r©ÚPollingObserver©ÚKqueueObserver©ÚWindowsApiObserver©ÚInotifyObserver©ÚFSEventsObserver©ÚObserver©r™zNo z key specified in r—Nr~rO)1Údebug_force_pollingÚwatchdog.observers.pollingrÚdebug_force_kqueueÚwatchdog.observers.kqueuerŸrÚdebug_force_winapir Ú
is_windowsÚ)watchdog.observers.read_directory_changesr¡Údebug_force_inotifyÚwatchdog.observers.inotifyr£Údebug_force_fseventsÚwatchdog.observers.fseventsr¥Úwatchdog.observersr§rkrcÚ python_pathr“r™ÚosrgÚexistsÚOSErrorÚerrnoÚENOENTÚstrerrorrtÚCONFIG_KEY_TRICKSÚKeyErrorÚCONFIG_KEY_PYTHON_PATHÚdirnameÚrelpathÚgetcwdrr|rÚappendrr
Úunschedule_allr„r…)rrÚ observer_clsrŸÚ observersÚ tricks_filer†ÚconfigrÚerrorÚdir_pathÚos r!Ú tricks_fromrÌÙðb ×ÒÝ&‰ Ø
× Ò Ý%‰ Ý × 7Ò 7½]Ìx×ObÑObÔOdÝ)‰ Ø
× !Ò !Ý&‰ Ø
× "Ò "Ý'‰ õˆ ä”J˜t×€IØ—z‘zó Ù¨¯ © Ôäw‰w~‰~˜kÔœ%Ÿ,™,¬¯ © ´E·L±LÓ(AÀ;Ó ˜[ÓðÔ.ˆFô
"  ˜FÔ#9Ñ —77—?? O´2·7±7·?±?Ä2Ç9Á9Ã;Ó3OˆÜ˜ &¨(¸d¿n¹nÕÔØ×јÖ"ð)#ð,ØÜ J‰JqŒMðøôòÔ.Ð.@ÀÀÈqÐQˆEܘ5“/ qÐ (ûð )ûô Øò ˆAØ
× Ñ Ô Ø
F‰F ðúðòˆØ ñs*Ä< HÇ/H0È H-ÈH(È(H-È00I#É"I#Ú trick_pathsz5Dotted paths for all the tricks you want to generate.z--append-to-filez€
Appends the generated tricks YAML to a file.
If not specified, prints to standard output.z-az
--append-onlyÚ append_onlyz
If --append-to-file is not specified, produces output for
appending instead of a complete tricks YAML file.)r=r;rzgenerate-tricks-yamlcó®ddl}t|j«}t|«t «}|j
D],}t
|«}|j|j««Œ.|j«}|j«|jt|i«}|tdz
}|j€1|js||z}t j"j|«yt$j&j)|j«s||z}t+|jdd¬«5}|j|«ddd«y#1swYyxYw)zLCommand to generate Yaml configuration for tricks named on the command line.rNz:
Úazutf-8)Úencoding)rnrcrkrr ÚwriteÚ
generate_yamlÚgetvalueÚcloseÚdumpr¾Úappend_to_filerÎrfÚstdoutr¶rgro) rrnÚ python_pathsÚoutputÚ
trick_pathrÚcontentÚheaderÚfiles r!Útricks_generate_yamlrßHsóBä˜d×/€LÜ
Z€Fà×0ˆ
ܘzÓ*ˆ Ø o‰oÓ€GØ
‡LL„Nà
Y‰YÔ Ð
>€FØ
Ô# '€FØ ×ÑÐ×ÒØ˜&ˆ
×јÕw‰w~‰~˜dט&ˆ
$×% s°WÔ
 ÀØ J‰J ÷ ÷ ñ ús Ä0E Å EÚ directoriesz%Directories to watch. (default: '.').)r•r˜rz-pz --patternz
--patternsryz9Matches event paths with these patterns (separated by ;).)r=r˜rz-iz--ignore-patternz--ignore-patternsrzrHz9Ignores event paths with these patterns (separated by ;).z-Dz--ignore-directoriesÚignore_directorieszIgnores events for directories.z-Rz%Monitors the directories recursively.z2Use this as the polling interval/blocking timeout.códdlm}t|j|j«\}}||||j
¬«}|j r ddlm}|}n||jr ddl
m }|}ngts |jstrtj«r ddlm}|}n2|j$r ddlm} | }n|j*r ddlm}
|
}ndd lm} | }||j4¬
«} t7| ||j8|j:¬ «y )
z1Command to log file system events to the console.r)Ú LoggerTrick)ryrzr r~N)Úwatchdog.tricksrãr{ryrzrrr­r r™rˆr|)
rryrzrrr†s
r!ÚlogråõN,ä .¨t¯}©}¸d×>RÑ>RÓ SÑ€HˆØØ×€Gð ×ÒÝ&‰ Ø
× Ò Ý%‰ Ý × 7Ò 7½]Ìx×ObÑObÔOdÝ)‰ Ø
× !Ò !Ý&‰ Ø
× "Ò "Ý'‰ õˆ á D§L¡LÔ1€Hܘ7 D×$4Ñ$4ÀÇÁÖOr"zDirectories to watch.z-cz --commandr]am
Shell command executed in response to matching events.
These interpolation variables are available to your command string:
${watch_src_path} - event source path
${watch_dest_path} - event destination path (for moved events)
${watch_event_type} - event type
${watch_object} - 'file' or 'directory'
Note:
Please ensure you do not use double quotes (") to quote
your command string. That will force your shell to
interpolate before the command is processed by this
command.
Example:
--command='echo "${watch_src_path}"'
F)r=r˜r;rz-wz--waitÚwait_for_processzDWait for process to finish to avoid multiple simultaneous instances.z-Wz--dropÚdrop_during_processzhIgnore events that occur while command is still being executed to avoid multiple simultaneous instances.cóŽddlm}|jsd|_|jr ddlm}|}nddlm}|}t|j|j«\}}||j|||j|j|j¬«}||j¬«}t|||j |j"¬«y) zDCommand to execute shell commands in response to file system events.r)ÚShellCommandTrickNrœ)ryrzr~)r]rr´r{ryrzr™rˆr|) rrryrzrr†s r!Ú
shell_commandrêôõn <Š<؈Œ ð ×ÒÝ&‰ åˆ ä .¨t¯}©}¸d×>RÑ>RÓ SÑ€HˆØ ØØ×× ×
€Gñ D§L¡LÔ1€Hܘ7 D×$4Ñ$4ÀÇÁÖOr"z,Long-running command to run in a subprocess.)rÚ command_argsÚargz€
Command arguments.
Note: Use -- before the command arguments, otherwise watchmedo will
try to interpret them.
)Úmetavarr•rz-dz --directoryÚ DIRECTORYrÂzLDirectory to watch. Use another -d or --directory option for each directory.)r=r;rz--signalÚsignalÚSIGINTz6Stop the subprocess with this signal (default SIGINT).z --kill-afterÚ
kill_afterg$@zYWhen stopping, kill the subprocess after the specified timeout in seconds (default 10.0).z--debounce-intervalÚdebounce_intervalgzwAfter a file change, Wait until the specified interval (in seconds) passes with no file changes, and only then restart.z--no-restart-on-command-exitÚrestart_on_command_exitÚ store_falsez.Don't auto-restart the command after it exits.c
óÄ
|jr ddlm}|}nddlm}|}ddlŠ
ddlm}|jsdg|_|j
jd«rt
|j
«nt|j
«}
j
jhŠt
d«rj
j «d
ˆ
ˆfd „ }D]}
j ||«Œt#|j$|j&«\}} |j(g}
|
j+|j,«||
|| |j.||j0|j2|j4¬
«} | j7«||j8¬ «} t;| | |j|j<¬ «| jA«y#t>$rYŒwxYw#| jA«wxYw)zLCommand to start a long-running subprocess and restart it on matched events.rN)ÚAutoRestartTrickr—ÚSIGÚSIGHUPcóVD]}j|j«Œ t)N)ÚSIG_IGNr
)Ú_signumÚ_frameÚsignumrïÚtermination_signalss €€r!Úhandler_termination_signalz0auto_restart.<locals>.handler_termination_signalàs*ø€à 2ˆ M‰M˜& &§.¡.Õ #r")ryrzÚ stop_signalrñÚdebounce_interval_secondsrór~)zsignal._SIGNUMrüÚobjectr0r1)!r©rr´Ú
startswithrŒr/ÚSIGTERMrðÚhasattrÚaddrør{ryrzr]Úextendrërr™rˆr|r
r„)rrrrÿryrzr]rr†s @@r!Ú auto_restartrgs“ù€ð~ ×ÒÝ&‰ åˆ ãå × Ò Ø˜5ˆÔð37·+±+×2HÑ2HÈÔ2O”'˜& $§+¡+Ô.ÔUXÐY]×YdÑYdÓUe€Kð"Ÿ>™>¨6¯=©=Ðäˆv Ø×Ñ §
¡
Ô :ˆØ
!/¨t¯}©}¸d×>RÑ>RÓ SÑ€Hˆ|‰|ˆn€GØ ‡NNØØØ×Ø—??Ø"&×"8Ñ"8Ø $× <Ñ <ô €Gð ‡MM„OÙ D§L¡LÔ1€HðÜX˜w¨×(8Ñ(8ÀDÇNÁNÕ  øô 
Ù ð
ûð  ús$Æ
#F>Æ> G
ÇG
Ç G
Ç
G
Ç
Gcó eZdZy)Ú
LogLevelErrorN)r'r4r5r\r"r!r
r
sØr"r
cót|jxsg«}|dkr
d}t|«|dkDr
d}t|«gd¢d|zS)NrMz&-q/--quiet may be specified only once.éz,-v/--verbose may be specified up to 2 times.)ÚERRORÚWARNINGÚINFOÚDEBUGrO)ÚsumrKr
)rrKs r!Ú_get_log_level_from_argsrsRÜD—N( bÓ)€IØ28ˆÜ˜1>ˆÜ˜ °Y±Ñ ?r"cóÔtj«}|jtj«y t |«}tjd«j|« |j|«y#t
$rV}t
d|jdtj¬«t|jj«Yd}~yd}~wwxYw#t$rYywxYw)zEntry-point function.NrOzError: r)Úwatchdogé‚)ÚcliÚ
parse_argsr<Ú
print_helprr
ÚprintrrfÚstderrrSÚloggingÚ getLoggerÚsetLevelrPÚKeyboardInterrupt)rÚ log_levelÚexcs r!Úmainr!ä >‰>Ó €DØ ×ÑÐÜ ÔØðÜ,¨TÓ2ˆ ô