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

243 lines
25 KiB
Plaintext
Raw Normal View History

Ë
JÀjlcãóº—dZddlmZddlZddlZddlZddlZddlZddlZddl m
Z
m Z ddl m
Z
ddlmZddlmZmZddlmZmZmZdd lmZer dd
l mZmZdd lmZdd lmZdd
lmZddl m!Z!ejDejF¬«dZ$dZ%Gd„de «Z&dZ'e
e'e&¬«Z(e(jSdde¬«e(jUd¬«Z+iZ,e-e.e/efZ0d�d„Z1e+ddœ džd„Z2ejfdœdŸd„Z4dd œd d!„Z5d¡d"„Z6d#dœ d¢d$„Z7 d£d&„Z8d¤d'„Z9e2e1d(d)d*¬+«e1d,d-d.ejf›d/�¬0«e1d1d2d3d4e:d5¬6«e1d7d8d9d:¬;«e1d<d8d=¬>«e1d?d8d@¬>«e1dAd8dB¬>«e1dCd8dD¬>«e1dEd8dF¬>«g dg¬G«d¥dH„«Z;e2e1dId)dJ¬+«e1d,d-d.ejf›d/�¬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¬€«e1d�d‚dTdƒd„d…¬†«e1dWdXdYdZd)d[¬\«e1d]d^d_d`dadb¬\«e1dcdddedpd8df¬q«e1dgd7d%d8dh¬Q«e1d1d2d3d4e:di¬6«e1d‡dˆd‰dЬ\«e1d<d8d=¬>«e1d‹dŒd�e:dެ6«e1d�d�d‘e:d’¬6«e1d“d”d9d•d–¬q«g
«d¥d—„«Z?Gd˜„d™e@«ZAd¦dš„ZBd§d›„ZCeDdœk(rejŠeC««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ˆfd„Zdd„Zd d„Zˆ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ó4—dt|«j›d�S)Nú<ú>)ÚtypeÚ__name__)rs r!Ú__repr__zHelpFormatter.__repr__5s€Ø”4˜“:×&Ñ&Ð' qÐ)Ð)r"cóZ—t|«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)NÚ_ú-Ú)Ú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>.decoratordsÚø€Ø�}‰}×$Ñ$ S¨#Ó.ˆÜ�d—l‘lÒ( bÓ)ˆØ×"Ñ" 4°Ò1BÀÐPTÔfsÐ"ÓtˆØ &Œ˜ÑØ ×=Ñ=Ó?ˆØ×$Ñ$ T¨9¸;È~ÐegÐ$ÔhØ×$Ñ$ T¨;¸[ÐQ_ÐghÐ$ÔiØ%)ò +Ñ !ˆM˜6Ø ˆF× Ñ  Ð 9°&Ò 9Ø × Ñ  TÐ Õ *ð +ðˆ 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€ð × Ñ ˜yÓ )Ð)r")Úindexcó^—|ddd…D]"}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ò)ˆÜ �‰�‰˜˜xÕ(ñ)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.
rNÚrb)ÚyamlÚopenÚ safe_loadÚread)Útricks_file_pathnamernÚfs r!Ú load_configrtŒs;€óä
Ð" DÓ )ð(¨QØ�~‰~˜aŸf™f›hÓ'÷(÷(ò(ú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>€ð ×"Ñ" 9Ó-€HØ*×0Ñ0°Ó;€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ÐÕGðHà ‡N�NÔðØÜ �J‰J�qŒMðøä òØ�
‰
Žðúà ‡M�M…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�%Ü" 4Ó(ˆIÙÑ( %Ñ(ˆGÜ$ WÐ.@À$ÓGÒSÈ8ˆNØ × Ñ ˜g ~ÀÐ Õ Kñ  LñLr"ÚfilesÚ*zperform tricks from given file)ÚnargsÚhelpz
--python-pathú.zPaths separated by z to add to the Python path.)Údefaultr–z
--intervalz --timeoutÚtimeoutgð?z?Use this as the polling interval/blocking timeout (in seconds).)r=r˜r&r–z --recursiveÚ
store_trueTz-Recursively monitor paths (defaults to True).)r;r˜r–z--debug-force-pollingz[debug] Forces polling.)r;r–z--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 tB›d
| ›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Úgetcwdr’r|r�Úappendr‚rƒr
Úunschedule_allr„r…)rr�Ú observer_clsrŸr¡r£r¥r§Ú observersÚ tricks_filer†ÚconfigrÚeÚerrorÚdir_pathÚos r!Ú tricks_fromrÌÙsý€ðb ×ÒÝ>à&‰ Ø
× Ò Ý<à%‰ Ý × 7Ò 7½]Ìx×ObÑObÔOdÝPà)‰ Ø
× !Ò !Ý>à&‰ Ø
× "Ò "Ý@à'‰ õ 0àˆ ä”J˜t×/Ñ/Ó0Ô1Ø€IØ—z‘zó#ˆ Ù¨¯ © Ô5ˆä�w‰w�~‰~˜kÔ*Üœ%Ÿ,™,¬¯ © ´E·L±LÓ(AÀ;ÓOÐ Oä˜[Ó)ˆð )ØÔ-Ñ.ˆFô
" VÑ +Ü ˜FÔ#9Ñ:Ô ;ä—7‘7—?‘? ;Ó/ÒO´2·7±7·?±?Ä2Ç9Á9Ã;Ó3OˆÜ˜ &¨(¸d¿n¹nÕMØ�‰ÔØ×јÖ"ð)#ð,ØÜ �J‰J�qŒMðøôò )ØÔ+Ð.Ð.@ÀÀÈqÐQˆEܘ5“/ qÐ (ûð )ûô !òØò ˆAØ
× Ñ Ô Ø
�F‰F�Hò ðúðòˆØ �‰�ñ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;r–zgenerate-tricks-yamlcó®—ddl}t|j«}t|«t «}|j
D],}t
|«}|j|j««Œ.|j«}|j«|jt|i«}|t›d�z
}|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)rnrcrµrkrrÍr ÚwriteÚ
generate_yamlÚgetvalueÚcloseÚdumpr¾r¼Úappend_to_filerÎrfÚstdoutr¶rgr·ro) rrnÚ python_pathsÚoutputÚ
trick_pathr�ÚcontentÚheaderÚfiles r!Útricks_generate_yamlrßHs€óBä˜d×.Ñ.Ó/€LÜ�LÔ!Ü
‹Z€Fà×&Ñ&ò0ˆ
ܘzÓ*ˆ Ø� ‰ �Y×,Ñ,Ó.Õ/ð0ð�o‰oÓ€GØ
‡L�L„Nà
�Y‰YÔ.° Ð=Ó
>€FØ
Ô"Ð# 3Ð'Ñ'€FØ ×ÑÐ"à×ÒØ˜wÑ&ˆGÜ �
‰
×јÕ!ä�w‰w�~‰~˜d×1Ñ1Ô2ؘwÑ&ˆGÜ
�$×%Ñ% s°WÔ
=ð ÀØ �J‰J�wÔ ÷ ÷ ñ ús Ä0E Å EÚ directoriesz%Directories to watch. (default: '.').)r•r˜r–z-pz --patternz
--patternsryz9Matches event paths with these patterns (separated by ;).)r=r˜r–z-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œržr r¢r¤r¦r¨r~N)Úwatchdog.tricksrãr{ryrzrár©rªr�r«r¬rŸrr­r r®r¯r¡r°r±r£r²r³r¥r´r§r™rˆràr|)
rrãryrzr�r�rÄrŸr¡r£r¥r§r†s
r!Úlogrå„sÒ€õN,ä .¨t¯}©}¸d×>RÑ>RÓ SÑ€HˆoÙØØ'Ø×2Ñ2ô€Gð ×ÒÝ>à&‰ Ø
× Ò Ý<à%‰ Ý × 7Ò 7½]Ìx×ObÑObÔOdÝPà)‰ Ø
× !Ò !Ý>à&‰ Ø
× "Ò "Ý@à'‰ õ 0àˆ á 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;r–z-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œr¦)ryrzrárærçr¨r~)rärér]r©rªr�r´r§r{ryrzrárærçr™rˆràr|) rrér�rÄr§ryrzr�r†s r!Ú
shell_commandrêôs¦€õn2à �<Š<؈Œ ð ×ÒÝ>à&‰ å/àˆ ä .¨t¯}©}¸d×>RÑ>RÓ SÑ€HˆoÙØ � ‰ ØØ'Ø×2Ñ2Ø×.Ñ.Ø ×4Ñ4ô
€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•r–z-dz --directoryÚ DIRECTORYrÂzLDirectory to watch. Use another -d or --directory option for each directory.)r=rír;r–z--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«r‰j‰
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.rrœr¦N)ÚAutoRestartTrickr—ÚSIGÚSIGHUPcóV•—‰D]}‰j|‰j«Œ t‚)N)rïÚSIG_IGNr
)Ú_signumÚ_frameÚsignumrïÚtermination_signalss €€r!Úhandler_termination_signalz0auto_restart.<locals>.handler_termination_signalàs*ø€à)ò 2ˆFØ �M‰M˜& &§.¡.Õ 1ð 2ä#Ð#r")ryrzráÚ stop_signalrñÚdebounce_interval_secondsrór¨r~)rûzsignal._SIGNUMrüÚobjectr0r1)!r©rªr�r´r§rïräröràÚ
startswithrŒr/ÚSIGTERMrðÚhasattrÚaddrør{ryrzr]Úextendrërárñròrór�r™rˆr|r
r„)rr�rÄr§rörrÿrýryrzr]r�r†rïrþs @@r!Ú auto_restartrgs“ù€ð~ ×ÒÝ>à&‰ å/àˆ ãå0à × Ò Ø˜5ˆÔð37·+±+×2HÑ2HÈÔ2O”'˜& $§+¡+Ô.ÔUXÐY]×YdÑYdÓUe€Kð"Ÿ>™>¨6¯=©=Ð9Ðäˆv�xÔ Ø×Ñ §
¡
Ô.ö$ð &ò:ˆØ�
‰
�fÐ8Õ9ð:ô!/¨t¯}©}¸d×>RÑ>RÓ SÑ€HˆoØ�|‰|ˆn€GØ ‡N�N�4×$Ñ$Ô%ÙØØØ'Ø×2Ñ2ØØ—?‘?Ø"&×"8Ñ"8Ø $× <Ñ <ô €Gð ‡M�M„OÙ D§L¡LÔ1€HðÜ�X˜w¨×(8Ñ(8ÀDÇNÁNÕSð � ‰ �øô !ò
Ù ð
ûð � ‰ �ú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
)rrKrÉs r!Ú_get_log_level_from_argsrsR€Ü�D—N‘NÒ( bÓ)€IØ�2‚~Ø8ˆÜ˜EÓ"Ð"Ø�1‚}Ø>ˆÜ˜EÓ"Ð"Ú 0°°Y±Ñ ?Ð?r"cóÔ—tj«}|j€tj«y t |«}tjd«j|« |j|«y#t
$rV}t
d|jd›�tj¬«t|jj«Yd}~yd}~wwxYw#t$rYywxYw)zEntry-point function.NrOzError: r)rÞÚwatchdogé‚)ÚcliÚ
parse_argsr<Ú
print_helprr
ÚprintrrfÚstderrrSÚloggingÚ getLoggerÚsetLevelrPÚKeyboardInterrupt)rÚ log_levelÚexcs r!Úmainr!s€ä �>‰>Ó €DØ ×ÑÐÜ �‰ÔØðÜ,¨TÓ2ˆ ô