Ë
    RPfÛ6  ã                    óP  — 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mZ d dlZddlmZ ddlmZ dZ e j.                  d	«      Z G d
„ de«      Zeeef   Z	 e	r?d dlZd dlmZ d dlZeej>                  ej>                  ej>                  f   Z  G d„ de«      Z! e«       ddddddddddddœdeeef   deedege"f      de#de#ded   de#de"de"de"dee"   d e#d!e"d"ee"   d#eee   ddf   fd$„Z$ e«       ddddddddddddœdeeef   deeeege"f      de#de#ded%   dee#   de"de"dee"   dee"   d e#d!e"d"ee"   d#e
ee   df   fd&„Z%d'eee#ef      deeeege"f      d#ee   fd(„Z&d)ee   d#dfd*„Z'd+ee#   d#e#fd,„Z(dee"   d#e"fd-„Z)d#e"fd.„Z*d"ee"   d#e"fd/„Z+y)0é    N)ÚIntEnum)ÚPath)ÚTYPE_CHECKINGÚAsyncGeneratorÚCallableÚ	GeneratorÚOptionalÚSetÚTupleÚUnioné   )Ú
RustNotify)ÚDefaultFilter)ÚwatchÚawatchÚChangeÚ
FileChangezwatchfiles.mainc                   ó.   — e Zd ZdZdZ	 dZ	 dZ	 defd„Zy)r   z=
    Enum representing the type of change that occurred.
    r   é   é   Úreturnc                 ó   — | j                   S ©N)Úname©Úselfs    úI/var/www/fastapitest/venv/lib/python3.12/site-packages/watchfiles/main.pyÚraw_strzChange.raw_str   s   € Ø�y‰yÐó    N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚaddedÚmodifiedÚdeletedÚstrr   © r   r   r   r      s-   „ ñð €EØ,Ø€HØTØ€GØ*ð˜ô r   r   )ÚProtocolc                   ó   — e Zd Zdefd„Zy)ÚAbstractEventr   c                  ó   — y r   r(   r   s    r   Úis_setzAbstractEvent.is_set1   s   € Ør   N)r    r!   r"   Úboolr-   r(   r   r   r+   r+   0   s   „ ð	˜Dô 	r   r+   i@  é2   éˆ  FTi,  )Úwatch_filterÚdebounceÚstepÚ
stop_eventÚrust_timeoutÚyield_on_timeoutÚdebugÚraise_interruptÚforce_pollingÚpoll_delay_msÚ	recursiveÚignore_permission_deniedÚpathsr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r   c              '   ó  K  — t        |«      }t        |«      }t        |D �cg c]  }t        |«      ‘Œ c}|||	|
|«      5 }	 |j	                  ||||«      }|dk(  r%|rt        «       –— n…t        j                  d«       no|dk(  r'|rt        ‚t        j                  d«       	 ddd«       y|dk(  r
	 ddd«       yt        || «      }|rt        |«       |–— nt        j                  d|«       Œ®c c}w # 1 sw Y   yxY w­w)aj  
    Watch one or more paths and yield a set of changes whenever files change.

    The paths watched can be directories or files, directories are watched recursively - changes in subdirectories
    are also detected.

    #### Force polling

    Notify will fall back to file polling if it can't use file system notifications, but we also force notify
    to us polling if the `force_polling` argument is `True`; if `force_polling` is unset (or `None`), we enable
    force polling thus:

    * if the `WATCHFILES_FORCE_POLLING` environment variable exists and is not empty:
       * if the value is `false`, `disable` or `disabled`, force polling is disabled
       * otherwise, force polling is enabled
    * otherwise, we enable force polling only if we detect we're running on WSL (Windows Subsystem for Linux)

    Args:
        *paths: filesystem paths to watch.
        watch_filter: callable used to filter out changes which are not important, you can either use a raw callable
            or a [`BaseFilter`][watchfiles.BaseFilter] instance,
            defaults to an instance of [`DefaultFilter`][watchfiles.DefaultFilter]. To keep all changes, use `None`.
        debounce: maximum time in milliseconds to group changes over before yielding them.
        step: time to wait for new changes in milliseconds, if no changes are detected in this time, and
            at least one change has been detected, the changes are yielded.
        stop_event: event to stop watching, if this is set, the generator will stop iteration,
            this can be anything with an `is_set()` method which returns a bool, e.g. `threading.Event()`.
        rust_timeout: maximum time in milliseconds to wait in the rust code for changes, `0` means no timeout.
        yield_on_timeout: if `True`, the generator will yield upon timeout in rust even if no changes are detected.
        debug: whether to print information about all filesystem changes in rust to stdout.
        raise_interrupt: whether to re-raise `KeyboardInterrupt`s, or suppress the error and just stop iterating.
        force_polling: See [Force polling](#force-polling) above.
        poll_delay_ms: delay between polling for changes, only used if `force_polling=True`.
        recursive: if `True`, watch for changes in sub-directories recursively, otherwise watch only for changes in the
            top-level directory, default is `True`.
        ignore_permission_denied: if `True`, will ignore permission denied errors, otherwise will raise them by default.
            Setting the `WATCHFILES_IGNORE_PERMISSION_DENIED` environment variable will set this value too.

    Yields:
        The generator yields sets of [`FileChange`][watchfiles.main.FileChange]s.

    ```py title="Example of watch usage"
    from watchfiles import watch

    for changes in watch('./first/dir', './second/dir', raise_interrupt=False):
        print(changes)
    ```
    Útimeoutúrust notify timeout, continuingÚsignalz(KeyboardInterrupt caught, stopping watchNÚstopú(all changes filtered out, raw_changes=%s)Ú_default_force_pollingÚ!_default_ignore_permission_deniedr   r'   r   ÚsetÚloggerr7   ÚKeyboardInterruptÚwarningÚ_prep_changesÚ_log_changes)r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   ÚpÚwatcherÚraw_changesÚchangess                    r   r   r   5   s  è ø€ ô~ +¨=Ó9€MÜ@ÐAYÓZÐÜ	ØÖ�AŒˆQ�Ò ¨°}ÀiÐQió
ð Zà	ØØ!Ÿ-™-¨°$¸ÀjÓQˆKØ˜iÒ'Ù#Ü›%“Kä—L‘LÐ!BÕCØ Ò(Ù"Ü+Ð+ä—N‘NÐ#MÔNØ÷Zð Zð   Ò&Ø÷#Zð Zô& (¨°\ÓB�ÙÜ  Ô)Ø!“Mä—L‘LÐ!KÈ[ÔYð+ ùò 	 ÷Zð Züs@   ‚ D¢C0´DÁ A#C5Â#	DÂ,C5Â2	DÂ;5C5Ã0DÃ5C>Ã:DÚAnyEventc           	     óÂ  K  — |�t        j                  dt        «       |€t        j                  «       }n|}t        |«      }t        |«      }t        |D �cg c]  }t        |«      ‘Œ c}|||	|
|«      5 }t        |«      }t        j                  «       }	 t        j                  «       4 ƒd{  –—† }	 t        j                  j                  |j                  ||||«      ƒ d{  –—† }|j"                  j%                  «        ddd«      ƒd{  –—†  dk(  r&|rt!        «       ­–— njt&        j)                  d«       nT|dk(  r
	 ddd«       y|dk(  rt+        d«      ‚t-        || «      }|rt/        |«       |­–— nt&        j)                  d|«       Œýc c}w 7 Œé7 Œµ# |t        f$ r |j!                  «        ‚ w xY w7 Œ­# 1 ƒd{  –—†7  sw Y   Œ½xY w# 1 sw Y   yxY w­w)	aú  
    Asynchronous equivalent of [`watch`][watchfiles.watch] using threads to wait for changes.
    Arguments match those of [`watch`][watchfiles.watch] except `stop_event`.

    All async methods use [anyio](https://anyio.readthedocs.io/en/latest/) to run the event loop.

    Unlike [`watch`][watchfiles.watch] `KeyboardInterrupt` cannot be suppressed by `awatch` so they need to be caught
    where `asyncio.run` or equivalent is called.

    Args:
        *paths: filesystem paths to watch.
        watch_filter: matches the same argument of [`watch`][watchfiles.watch].
        debounce: matches the same argument of [`watch`][watchfiles.watch].
        step: matches the same argument of [`watch`][watchfiles.watch].
        stop_event: `anyio.Event` which can be used to stop iteration, see example below.
        rust_timeout: matches the same argument of [`watch`][watchfiles.watch], except that `None` means
            use `1_000` on Windows and `5_000` on other platforms thus helping with exiting on `Ctrl+C` on Windows,
            see [#110](https://github.com/samuelcolvin/watchfiles/issues/110).
        yield_on_timeout: matches the same argument of [`watch`][watchfiles.watch].
        debug: matches the same argument of [`watch`][watchfiles.watch].
        raise_interrupt: This is deprecated, `KeyboardInterrupt` will cause this coroutine to be cancelled and then
            be raised by the top level `asyncio.run` call or equivalent, and should be caught there.
            See [#136](https://github.com/samuelcolvin/watchfiles/issues/136)
        force_polling: if true, always use polling instead of file system notifications, default is `None` where
            `force_polling` is set to `True` if the `WATCHFILES_FORCE_POLLING` environment variable exists.
        poll_delay_ms: delay between polling for changes, only used if `force_polling=True`.
        recursive: if `True`, watch for changes in sub-directories recursively, otherwise watch only for changes in the
            top-level directory, default is `True`.
        ignore_permission_denied: if `True`, will ignore permission denied errors, otherwise will raise them by default.
            Setting the `WATCHFILES_IGNORE_PERMISSION_DENIED` environment variable will set this value too.

    Yields:
        The generator yields sets of [`FileChange`][watchfiles.main.FileChange]s.

    ```py title="Example of awatch usage"
    import asyncio
    from watchfiles import awatch

    async def main():
        async for changes in awatch('./first/dir', './second/dir'):
            print(changes)

    if __name__ == '__main__':
        try:
            asyncio.run(main())
        except KeyboardInterrupt:
            print('stopped via KeyboardInterrupt')
    ```

    ```py title="Example of awatch usage with a stop event"
    import asyncio
    from watchfiles import awatch

    async def main():
        stop_event = asyncio.Event()

        async def stop_soon():
            await asyncio.sleep(3)
            stop_event.set()

        stop_soon_task = asyncio.create_task(stop_soon())

        async for changes in awatch('/path/to/dir', stop_event=stop_event):
            print(changes)

        # cleanup by awaiting the (now complete) stop_soon_task
        await stop_soon_task

    asyncio.run(main())
    ```
    NzÄraise_interrupt is deprecated, KeyboardInterrupt will cause this coroutine to be cancelled and then be raised by the top level asyncio.run call or equivalent, and should be caught there. See #136.r?   r@   rB   rA   z+watch thread unexpectedly received a signalrC   )ÚwarningsÚwarnÚDeprecationWarningÚanyioÚEventrD   rE   r   r'   Ú_calc_async_timeoutÚget_cancelled_exc_classÚcreate_task_groupÚ	to_threadÚrun_syncr   rH   rF   Úcancel_scopeÚcancelrG   r7   ÚRuntimeErrorrJ   rK   )r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   Ústop_event_rL   rM   r?   ÚCancelledErrorÚtgrN   rO   s                        r   r   r   ‘   sË  è ø€ ðl Ð"Ü�‰ðoäô	
ð ÐÜ"'§+¡+£-‰à ˆä*¨=Ó9€MÜ@ÐAYÓZÐÜ	ØÖ�AŒˆQ�Ò ¨°}ÀiÐQió
ð  Zà	Ü% lÓ3ˆÜ×6Ñ6Ó8ˆàÜ×.Ñ.Ó0÷ )ð )°BðÜ(-¯©×(@Ñ(@ÀÇÁÐPXÐZ^Ð`gÐitÓ(u×"u�Kð
 —‘×&Ñ&Ô(÷)÷ )ð ˜iÒ'Ù#Ü›%”Kä—L‘LÐ!BÕCØ Ò&Ø÷- Zð  Zð.  Ò(ä"Ð#PÓQÐQä'¨°\ÓB�ÙÜ  Ô)Ø!”Mä—L‘LÐ!KÈ[ÔYð5 ùò 	 ð)øà"uùØ&Ô(9Ð:ò Ø—O‘OÔ%àðúð)ø÷ )÷ )ñ )ú÷ Zð  Züs©   ‚AGÁFÁ)GÁ59GÂ.FÂ/GÂ2F>Â40FÃ$FÃ%FÃ)F>ÄGÄF<Ä5GÅ	GÅAGÆGÆGÆFÆF9Æ9F>Æ<GÆ>G	ÇGÇG	ÇGÇGÇGrN   c                 óœ   — | D ��ch c]  \  }}t        |«      |f’Œ }}}|r|D �ch c]  } ||d   |d   «      sŒ|’Œ }}|S c c}}w c c}w )Nr   r   )r   )rN   r1   ÚchangeÚpathrO   Úcs         r   rJ   rJ     sZ   € ð ;F×F©,¨&°$”�v“ Ò%ÐF€GÑFÙØ%ÖB˜©°a¸±d¸A¸a¹DÕ)A’1ÐBˆÐBØ€Nùó GùâBs   †A¦A	»A	rO   c                 ó  — t         j                  t        j                  «      rht	        | «      }|dk(  rdnd}t         j                  t        j
                  «      rt         j                  d||| «       y t         j                  d||«       y y )Nr   Ú Úsz%d change%s detected: %sz%d change%s detected)rG   ÚisEnabledForÚloggingÚINFOÚlenÚDEBUGr7   Úinfo)rO   ÚcountÚplurals      r   rK   rK   "  se   € Ü×Ñœ7Ÿ<™<Ô(Ü�G“ˆØ ’z‘ sˆÜ×ÑœwŸ}™}Ô-Ü�L‰LÐ3°U¸FÀGÕLä�K‰KÐ.°°vÕ>ð )r   r?   c                 ó4   — | €t         j                  dk(  ryy| S )zC
    see https://github.com/samuelcolvin/watchfiles/issues/110
    Úwin32iè  r0   )ÚsysÚplatform)r?   s    r   rW   rW   ,  s    € ð €Ü�<‰<˜7Ò"Øààˆr   c                 óp   — | �| S t        j                  d«      }|r|j                  «       dvS t        «       S )z™
    See docstring for `watch` above for details.

    See samuelcolvin/watchfiles#167 and samuelcolvin/watchfiles#187 for discussion and rationale.
    ÚWATCHFILES_FORCE_POLLING>   ÚfalseÚdisableÚdisabled)ÚosÚgetenvÚlowerÚ_auto_force_polling)r9   Úenv_vars     r   rD   rD   9  s=   € ð Ð ØÐÜ�i‰iÐ2Ó3€GÙØ�}‰}‹Ð&FÐFÐFä"Ó$Ð$r   c                  ó    — ddl } | j                  «       }d|j                  j                  «       v xr |j                  j                  «       dk(  S )z”
    Whether to auto-enable force polling, it should be enabled automatically only on WSL.

    See samuelcolvin/watchfiles#187 for discussion.
    r   Nzmicrosoft-standardÚlinux)rt   ÚunameÚreleaser|   Úsystem)rt   r�   s     r   r}   r}   H  sC   € ó à�N‰NÓ€EØ 5§=¡=×#6Ñ#6Ó#8Ð8Ò\¸U¿\¹\×=OÑ=OÓ=QÐU\Ñ=\Ð\r   c                 óJ   — | �| S t        j                  d«      }t        |«      S )NÚ#WATCHFILES_IGNORE_PERMISSION_DENIED)rz   r{   r.   )r<   r~   s     r   rE   rE   T  s'   € ØÐ+Ø'Ð'Ü�i‰iÐ=Ó>€GÜ�‹=Ðr   ),rj   rz   rs   rR   Úenumr   Úpathlibr   Útypingr   r   r   r   r	   r
   r   r   rU   Ú_rust_notifyr   Úfiltersr   Ú__all__Ú	getLoggerrG   r   r'   r   Úasyncior)   ÚtriorV   rP   r+   r.   Úintr   r   rJ   rK   rW   rD   r}   rE   r(   r   r   ú<module>r�      si  ðÛ Û 	Û 
Û Ý Ý ß b× bÓ bã å $Ý "à
3€Ø	ˆ×	Ñ	Ð,Ó	-€ôˆWô ð  �6˜3�;Ñ€
ðñ
 ÛÝãà�U—[‘[ '§-¡-°·±Ð;Ñ<€Hô˜ô ñ ?L»oØØØ,0ØØ"ØØ Ø$(ØØØ/3òYZØ�$˜�)ÑðYZà˜8 X¨s O°TÐ$9Ñ:Ñ;ðYZð ðYZð ð	YZð
 ˜Ñ)ðYZð ðYZð ðYZð ðYZð ðYZð ˜D‘>ðYZð ðYZð ðYZð ' t™nðYZð ˆs�:‰  dÐ*Ñ+óYZñ| =J»OØØØ'+Ø"&Ø"ØØ&*Ø$(ØØØ/3òDZØ�$˜�)ÑðDZà˜8 V¨S M°4Ð$7Ñ8Ñ9ðDZð ðDZð ð	DZð
 ˜Ñ$ðDZð ˜3‘-ðDZð ðDZð ðDZð ˜d‘^ðDZð ˜D‘>ðDZð ðDZð ðDZð ' t™nðDZð �C˜
‘O TÐ)Ñ*óDZðNØ�U˜3 ˜8‘_Ñ%ðØ5=¸hÈÐPSÀ}ÐVZÐGZÑ>[Ñ5\ðàˆ�_óð?˜#˜j™/ð ?¨dó ?ð
 ¨#¡ð 
°3ó 
ð%¨(°4©.ð %¸Tó %ð	]˜Tó 	]ðÀÈÁð ÐSWô r   