f6ddlZddlZddlZddlZddlZddlmZmZddlZ ddl m Z m Z m Z ddlmZe j ej"dZGddZGd d eZGd d eZy) N)ClassVarSequence)OpenFileget_filesystem_classsplit_protocol)known_implementationsz fsspec.guiceZdZUdZgZeeeed<gZ eeeed<dZ dZ de jdfdZd Zd Zd Zej&d ZddZddZy )SigSlotaSignal-slot mixin, for Panel event passing Include this class in a widget manager's superclasses to be able to register events and callbacks on Panel widgets managed by that class. The method ``_register`` should be called as widgets are added, and external code should call ``connect`` to associate callbacks. By default, all signals emit a DEBUG logging statement. signalsslotscNd|_i|_i|_|jy)NF)_ignoring_events_sigs_map_setupselfs S/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/fsspec/gui.py__init__zSigSlot.__init__%s! %   cJtjj|_y)z(Create GUI elements and register signalsN)pnpanePaneBasepanelrs rrzSigSlot._setup+sWW%%' rvalueFc ||jvrtd||g||d|j|<dj|t |dt |nd|g}||j |<|(|jj|j|d|r*t||r|j|t ||yyy) aWatch the given attribute of a widget and assign it a named event This is normally called at the time a widget is instantiated, in the class which owns it. Parameters ---------- widget : pn.layout.Panel or None Widget to watch. If None, an anonymous signal not associated with any widget. name : str Name of this event thing : str Attribute of the given widget to watch log_level : int When the signal is triggered, a logging event of the given level will be fired in the dfviz logger. auto : bool If True, automatically connects with a method in this class of the same name. z(Attempt to assign an undeclared signal: )widget callbacksthinglog-NnamenoneT) onlychanged) r ValueErrorrjoingetattrstrrparamwatch_signalhasattrconnect)rrr$r! log_levelautowns r _registerzSigSlot._register0s0 t|| #GvNO O   4 XX8>8JF 4PV    "   LL  t||U  E GD$' LLwtT2 3(4rc |jj|i|S#ttf$r}t d|d}~wwxYw)z!Display in a notebook or a serverz)Panel does not seem to be set up properlyN)r_repr_mimebundle_r'AttributeErrorNotImplementedError)rargskwargsexcs rr5zSigSlot._repr_mimebundle_\sK /4:://@@ @N+ %;  s> 9>cF|j|dj|y)aAssociate call back with given event The callback must be a function which takes the "new" value of the watched attribute as the only parameter. If the callback return False, this cancels any further processing of the given event. Alternatively, the callback can be a string, in which case it means emitting the correspondingly-named event (i.e., connect to self) r N)rappend)rsignalslots rr/zSigSlot.connectes  6;'..t4rc(|jsdj|jj|jg}||jvrF|j||j vr*|j |j||jyyyy)zThis is called by a an action on a widget Within an self.ignore_events context, nothing happens. Tests can execute this method by directly changing the values of widget components. r#N)rr(objr$rr_emitnew)reventr2s rr-zSigSlot._signalqsp$$599>>5::67BTYY499R=DJJ#> 499R=%))4$?%rc#JKd|_ dd|_y#d|_wxYww)zjTemporarily turn off events processing in this instance (does not propagate to children) TNF)rrs r ignore_eventszSigSlot.ignore_events~s( !% * $)D !ED !s## #NcDtj|j|d|d||j|dD]3}t|tr|j |% ||}|dury5y#t $r!}tjd||Yd}~\d}~wwxYw)zAn event happened, call its callbacks This method can be used in tests to simulate message passing without directly changing visual elements. Calling of callbacks will halt whenever one returns False. r"z: r Fz6Exception (%s) while executing callback for signal: %sN)loggerr"r isinstancer*rA Exception exception)rsigrcallbackretes rrAz SigSlot._emits  4::c?5)cU"UG+<= 3 4H(C( 8$ "5/Ce|$5!$$Ps$ A55 B>BBc@|jj|d|S)z