L i'ddlmZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z ddlmZej dk\rddlmZnddlmZej d k\rdd lmZndd lmZerdd lmZe d Ze d Zede defefZe dee Ze egeee fZddZGddeZGdde eefZGdde eefZ dZ!y)) annotationsN)partial) entry_points) TYPE_CHECKINGAnyCallableGenericTypeVarcast)deprecated_warn) )TypeIs)r ) TypeAliasType) TracebackTypeTRPlugin.) type_paramsPluginT)boundcdfd }|S)zq Converts a type to guard function. Added for compatibility with original `PluginRegistry` default. ct|SN) isinstance)objtps b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/altair/utils/plugin_registry.pyfuncz_is_type..func$s#r"")robjectreturnzTypeIs[type[T]])rr s` r_is_typer%s# Kr!ceZdZdZdZy)NoSuchEntryPointc ||_||_yr)groupname)selfr)r*s r__init__zNoSuchEntryPoint.__init__+s  r!c:d|jd|jS)NzNo z entry point found in group )r*r)r+s r__str__zNoSuchEntryPoint.__str__/sTYYM!=djj^LLr!N)__name__ __module__ __qualname__r,r/r$r!rr'r'*s Mr!r'c@eZdZdZ ddZddZd dZd dZy) PluginEnablera% Context manager for enabling plugins. This object lets you use enable() as a context manager to temporarily enable a given plugin:: with plugins.enable("name"): do_something() # 'name' plugin temporarily enabled # plugins back to original state c ||_||_||_|j|_|jj |fi|yr)registryr*options _get_stateoriginal_state_enable)r+r6r*r7s rr,zPluginEnabler.__init__?sC5=  '. .6.A.A.C d.g.r!c|Srr$r.s r __enter__zPluginEnabler.__enter__Hs r!cN|jj|jyr)r6 _set_stater9)r+typvalue tracebacks r__exit__zPluginEnabler.__exit__Ks   !4!45r!c`t|jjd|jdS)Nz.enable())typer6r0r*r.s r__repr__zPluginEnabler.__repr__Ns)t}}%../x }AFFr!N)r6zPluginRegistry[PluginT, R]r*strr7rr#None)r#PluginEnabler[PluginT, R])r?rEr@ ExceptionrArr#rHr#rG)r0r1r2__doc__r,r<rBrFr$r!rr4r43s< /2/:=/JM/ /6Gr!r4ceZdZUdZiZded<iZded<def ddZddZ dd Z dd Z dd Z dd Z d ddZeddZeddZddZddZy )PluginRegistrya A registry for plugins. This is a plugin registry that allows plugins to be loaded/registered in two ways: 1. Through an explicit call to ``.register(name, value)``. 2. By looking for other Python packages that are installed and provide a setuptools entry point group. When you create an instance of this class, provide the name of the entry point group to use:: reg = PluginRegister("my_entrypoint_group") zdict[str, str]entrypoint_err_messagesdict[str, Any]_global_settingsch||_||turUt|trEdt|jd}t |dt tt||_ n||_ d|_ d|_ i|_ i|_ |jjj!|_y)a Create a PluginRegistry for a named entry point group. Parameters ---------- entry_point_group: str The name of the entry point group. plugin_type A type narrowing function that will optionally be used for runtime type checking loaded plugins. References ---------- https://typing.readthedocs.io/en/latest/spec/narrowing.html zrYr\r[rZrQN)rjrfitemssetattr)r+statekeyvals rr>zPluginRegistry._set_statesK5::< %      $HC D#s # $r!c f|jvrQ fdt|jD\}t t|j}|j||_ |j|_ t|jt|jjzD] }|j||j|<"||_y#t$rC}|jvrt|j|t |j|d}~wwxYw)Nc3@K|]}|jk(r|ywr)r*).0rmr*s r z)PluginRegistry._enable..s$ww$s)r[rgrU ValueErrorrOr'r rloadrcrZrYrjrfrQrar\)r+r*r7rmerrr@rus ` rr:zPluginRegistry._enables  t}} $ R4T5K5KL"''),E MM$ & }}T* w||~&T-B-B-G-G-I)JJ :C)0S)9D ! !# & :  R4777$T%A%A$%GHcQ*4+A+A4HcQ  Rs C$$ D0->D++D0Nc 8| |j}t||fi|S)a& Enable a plugin by name. This can be either called directly, or used as a context manager. Parameters ---------- name : string (optional) The name of the plugin to enable. If not specified, then use the current active name. **options : Any additional parameters will be passed to the plugin as keyword arguments Returns ------- PluginEnabler: An object that allows enable() to be used as a context manager )activer4)r+r*r7s renablezPluginRegistry.enables$, <;;DT43733r!c|jS)z/Return the name of the currently active plugin.)rZr.s rrzPluginRegistry.actives   r!c|jS)z&Return the current options dictionary.)r\r.s rr7zPluginRegistry.optionss}}r!c@|jx}r5|j|r$|jrt|fi|jS|S|jCt |j dt |jj d}t |trty)z#Return the currently active plugin.Nz2 requires all plugins to be callable objects, but z is not callable.) rYrXr\rrEr0rbrNotImplementedError)r+r r_s rgetzPluginRegistry.getsLL D d&6&6t&<59]]7414==1 L L \\ %:&&)*DLL)2255FH C. & % r!cnt|jd|jd|jdS)Nz(active=z , registered=rD)rEr0rror.s rrFzPluginRegistry.__repr__s2t*%%&ht{{o]4::r:rpropertyrr7rrFr$r!rrNrNRs&/1^0(*n)(*8$W!$$W8@$W $WL!8!  $ ,"&44254 "44!!& ]r!rNcvt}t|dr|j|S|j|gS)Nselect)r))rhasattrrr)r)rms rrgrgs7 B r8yyuy%%vveR  r!)rztype[T]r#z#Callable[[object], TypeIs[type[T]]])" __future__rsys functoolsrimportlib.metadatartypingrrrr r r altair.utils.deprecationr version_infortyping_extensionsrtypesrrrrrr"rWr%rJr'r4rNrgr$r!rrs" +GG4w(w$/# CL CL x#q&!1t D )6#; / VHfVC[11 2 MyMGGGQJ'G>D]WWaZ(D]N !r!