
    $g                        d Z ddlmZ ddlZddlZddlmZ erddlmZ ddl	m
Z
  G d de          Z G d	 d
e          Z G d dej                  ZddZd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:

    )annotationsN)TYPE_CHECKING)
ModuleType)Trickc                      e Zd ZdS )UnsupportedLibcErrorN)__name__
__module____qualname__     W/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/watchdog/utils/__init__.pyr   r      s        Dr   r   c                      e Zd ZdZdS )WatchdogShutdownErrorz=Semantic exception used to signal an external shutdown event.N)r	   r
   r   __doc__r   r   r   r   r      s        GGGGr   r   c                  Z    e Zd ZdZddZedd            ZddZdd	Zdd
Z	ddZ
ddZdS )
BaseThreadz1Convenience class for creating stoppable threads.returnNonec                    t           j                            |            t          | d          rd| _        n|                     d           t          j                    | _        d S )NdaemonT)	threadingThread__init__hasattrr   	setDaemonEvent_stopped_eventselfs    r   r   zBaseThread.__init__&   s\    !!$'''4"" 	!DKKNN4   'o//r   threading.Eventc                    | j         S N)r   r   s    r   stopped_eventzBaseThread.stopped_event.   s    ""r   boolc                6    | j                                          S )z6Determines whether the thread should continue running.)r   is_setr   s    r   should_keep_runningzBaseThread.should_keep_running2   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_stop6         r   c                `    | j                                          |                                  dS )zSignals the thread to stop.N)r   setr*   r   s    r   stopzBaseThread.stop=   s/    !!!r   c                    dS )zOverride 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_startB   r+   r   c                l    |                                   t          j                            |            d S r#   )r0   r   r   startr   s    r   r2   zBaseThread.startJ   s1    t$$$$$r   N)r   r   )r   r!   )r   r%   )r	   r
   r   r   r   propertyr$   r(   r*   r.   r0   r2   r   r   r   r   r   #   s        ;;0 0 0 0 # # # X#0 0 0 0      
   % % % % % %r   r   module_namestrr   r   c                    	 t          |            n'# t          $ r}d|  }t          |          |d}~ww xY wt          j        |          S )z;Imports a module given its name and returns a handle to it.zNo module named N)
__import__ImportErrorsysmodules)r4   eerrors      r   load_moduler=   O   sc    (; ( ( (0;00%  a'( ;{##s    
616dotted_pathtype[Trick]c                R   |                      d          }t          |          dk    rd|  d}t          |          |d         }d                    |dd                   }t	          |          }t          ||          rt          ||          S d| d| }t          |          )	a  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.

    .   zDotted module path z+ must contain a module name and a classnameNzModule z does not have class attribute )splitlen
ValueErrorjoinr=   r   getattrAttributeError)r>   dotted_path_splitr<   
klass_namer4   modules         r   
load_classrM   Y   s    * $))#..
""^k^^^"2&J((,SbS122K%%Fvz"" +vz***NkNN*NNE


r   )r4   r5   r   r   )r>   r5   r   r?   )r   
__future__r   r9   r   typingr   typesr   watchdog.tricksr   	Exceptionr   r   r   r   r=   rM   r   r   r   <module>rS      s2    # " " " " " 



                 &      %%%%%%	 	 	 	 	9 	 	 	H H H H HI H H H)% )% )% )% )%! )% )% )%X$ $ $ $!  !  !  !  !  ! r   