
    zc                         d Z ddlZddlZ G d de          Z G d de          Z G d dej                  Zd	 Zd
 Z	dS )u  
:module: watchdog.utils
:synopsis: Utility classes and functions.
:author: yesudeep@google.com (Yesudeep Mangalapilly)
:author: contact@tiger-222.fr (Mickaël Schoentgen)

Classes
-------
.. autoclass:: BaseThread
   :members:
   :show-inheritance:
   :inherited-members:

    Nc                       e Zd ZdS )UnsupportedLibcN)__name__
__module____qualname__     7lib/python3.11/site-packages/watchdog/utils/__init__.pyr   r   %   s        Dr	   r   c                       e Zd ZdZdS )WatchdogShutdownzG
    Semantic exception used to signal an external shutdown event.
    N)r   r   r   __doc__r   r	   r
   r   r   )   s          	Dr	   r   c                   L    e Zd ZdZd Zed             Zd Zd Zd Z	d Z
d Zd	S )

BaseThreadz3 Convenience class for creating stoppable threads. c                 (   t           j                            |            t          | d          rd| _        n|                     d           t          j                    | _        t          | j        d          s| j        j        | j        _	        d S d S )NdaemonTis_set)
	threadingThread__init__hasattrr   	setDaemonEvent_stopped_eventisSetr   selfs    r
   r   zBaseThread.__init__3   s    !!$'''4"" 	!DKKNN4   'o//t*H55 	C)-)<)BD&&&	C 	Cr	   c                     | j         S N)r   r   s    r
   stopped_eventzBaseThread.stopped_event>   s    ""r	   c                 6    | j                                          S )z6Determines whether the thread should continue running.)r   r   r   s    r
   should_keep_runningzBaseThread.should_keep_runningB   s    &--////r	   c                     dS )zOverride this method instead of :meth:`stop()`.
        :meth:`stop()` calls this method.

        This method is called immediately after the thread is signaled to stop.
        Nr   r   s    r
   on_thread_stopzBaseThread.on_thread_stopF   s	     	r	   c                 `    | j                                          |                                  dS )zSignals the thread to stop.N)r   setr#   r   s    r
   stopzBaseThread.stopN   s/    !!!r	   c                     dS )u   Override this method instead of :meth:`start()`. :meth:`start()`
        calls this method.

        This method is called right before this thread is started and this
        object’s run() method is invoked.
        Nr   r   s    r
   on_thread_startzBaseThread.on_thread_startS   s	     	r	   c                 l    |                                   t          j                            |            d S r   )r(   r   r   startr   s    r
   r*   zBaseThread.start\   s1    t$$$$$r	   N)r   r   r   r   r   propertyr   r!   r#   r&   r(   r*   r   r	   r
   r   r   0   s        ==	C 	C 	C # # X#0 0 0    
  % % % % %r	   r   c                     	 t          |            n # t          $ r t          d| z            w xY wt          j        |          S )z;Imports a module given its name and returns a handle to it.zNo module named %s)
__import__ImportErrorsysmodules)module_names    r
   load_moduler2   a   sT    >; > > >.<===>;{##s    /c                 L   |                      d          }t          |          dk    rk|d         }d                    |dd                   }t          |          }t	          ||          rt          ||          }|S t          d|d|          t          d| z            )ak  Loads and returns a class definition provided a dotted path
    specification the last part of the dotted path is the class name
    and there is at least one module name preceding the class name.

    Notes:
    You will need to ensure that the module you are trying to load
    exists in the Python path.

    Examples:
    - module.name.ClassName    # Provided module.name is in the Python path.
    - module.ClassName         # Provided module is in the Python path.

    What won't work:
    - ClassName
    - modle.name.ClassName     # Typo in module name.
    - module.name.ClasNam      # Typo in classname.
    .   NzModule z does not have class attribute z@Dotted module path %s must contain a module name and a classname)splitlenjoinr2   r   getattrAttributeError
ValueError)dotted_pathdotted_path_split
klass_namer1   moduleklasss         r
   
load_classrB   j   s    $ $))#..
! ^&r*
hh0"566[))6:&& 	;FJ//EL !.!,jj": ; ; ; NQ\\^ ^ 	^r	   )
r   r/   r   	Exceptionr   r   r   r   r2   rB   r   r	   r
   <module>rD      s   &  


    	 	 	 	 	i 	 	 		 	 	 	 	y 	 	 	.% .% .% .% .%! .% .% .%b$ $ $"^ "^ "^ "^ "^r	   