K i dZddlmZddlZddlZddlmZer ddlmZddl m Z Gdde Z Gd d e Z Gd d ejZdd ZddZy)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 eZdZy)UnsupportedLibcErrorN)__name__ __module__ __qualname__]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/watchdog/utils/__init__.pyrrsr rceZdZdZy)WatchdogShutdownErrorz=Semantic exception used to signal an external shutdown event.N)r r r __doc__r r rrrsGr rcReZdZdZd dZed dZd dZd dZd dZ d dZ d dZ y ) BaseThreadz1Convenience class for creating stoppable threads.ctjj|t|drd|_n|j dtj |_y)NdaemonT) threadingThread__init__hasattrr setDaemonEvent_stopped_eventselfs rrzBaseThread.__init__&sB!!$' 4 "DK NN4 'oo/r c|jSN)rrs r stopped_eventzBaseThread.stopped_event.s"""r c8|jj S)z6Determines whether the thread should continue running.)ris_setrs rshould_keep_runningzBaseThread.should_keep_running2s&&--///r cy)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 rs ron_thread_stopzBaseThread.on_thread_stop6r cX|jj|jy)zSignals the thread to stop.N)rsetr&rs rstopzBaseThread.stop=s  ! r cy)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 rs ron_thread_startzBaseThread.on_thread_startBr'r cb|jtjj|yr )r,rrstartrs rr.zBaseThread.startJs" t$r N)returnNone)r/zthreading.Event)r/bool) r r r rrpropertyr!r$r&r*r,r.r r rrr#s7;0##0   %r rc t|tj|S#t$r}d|}t||d}~wwxYw)z;Imports a module given its name and returns a handle to it.zNo module named N) __import__ ImportErrorsysmodules) module_nameeerrors r load_moduler;OsK(; ;;{ ## (";-0% a'(s ?:?c|jd}t|dkrd|d}t||d}dj|dd}t |}t ||r t ||Sd|d|}t|) aLoads 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. .zDotted module path z+ must contain a module name and a classnameNzModule z does not have class attribute )splitlen ValueErrorjoinr;rgetattrAttributeError) dotted_pathdotted_path_splitr: klass_namer8modules r load_classrJYs*$))#. "%k]2]^"2&J((,Sb12K  %Fvz"vz**k]"A* NE  r )r8strr/r)rFrKr/z type[Trick])r __future__rr6rtypingrtypesrwatchdog.tricksr Exceptionrrrrr;rJr r rrQsX #   % 9 HIH)%!!)%X$! r