XBFjGV  dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZddlmZddlmZmZmZmZddlmZdd lmZdd lmZdd lmZmZmZe e!e"e#fZ$e%fZ&e j'rdd l(m)Z)ndd l m)Z)gd Z*edddZ+edddZ,e+Z-Gdde.Z/ddZ0ddZ1ddZ2dd!Z3Gd"d#Z4ddd'Z5dd*Z6Gd+d,Z7Gd-d.Z8e8Z9Gd/d0Z:e)d1Z;e)d2Z<e)d3Z=e j'r(dd4l(m>Z>m?Z?e)d5e@6ZAe)d7e jB6ZCne)d5ZAe)d7ZCGd8d9e:e jDe;ed?e%ZHGd@dAeHZIdBdCddGZJddJZKddLZLddOZMe j)dIe jNdPe jBfQZOGdRdSe:ZPGdTdFePZQGdUdKePZRGdVdNePZSGdWdXeHYZTGdZd[eTeIYZUGd\d]eEe;e>  rTt.Anyc` t|S#tttf$r|cYSwxYw)zwSafely evaluate an expression Returns original string if eval fails. Use only where types are ambiguous. )r NameError SyntaxError ValueErrorr`s rU_safe_literal_evalrfs>A {J /s --tct|tp)t|tot|tS)zHReturns whether the given value is an instance or subclass of TraitType.) isinstancer>type issubclass)rgs rUis_traitrls0 a # # Y 1d(;(;(X 1i@X@XYrTnames+Sentinel | str | t.Iterable[Sentinel | str]t.Iterable[t.Any]c:|tust|tr|gSt|trt d|r t|vrtgS|D]?}t|ts(t dt |jd|d@|S)aConvert the name argument to a list of names. Examples -------- >>> parse_notifier_name([]) [traitlets.All] >>> parse_notifier_name("a") ['a'] >>> parse_notifier_name(["a", "b"]) ['a', 'b'] >>> parse_notifier_name(All) [traitlets.All] z7`names` must be either `All`, a str, or a list of strs.znames must be strings, not ())rrirWr TypeErrorrjrP)rmns rUrLrLs ||z%--|w E8 $ $QRRR u 5L Y YAa%% Y Wd1gg>N W WQR W W WXXX Y rTc.eZdZd dZddZdd Zdd Zd S) _SimpleTestvaluerarXNonec||_dSNrwselfrws rU__init__z_SimpleTest.__init__s  rTtestrYc2t||jkSrz)rYrw)r}rs rU__call__z_SimpleTest.__call__sDDJ&'''rTrWcd|jzS)Nz>> class X(HasTraits): ... value = Int() >>> src = X(value=1) >>> tgt = X(value=42) >>> c = link((src, "value"), (tgt, "value")) Setting source updates target objects: >>> src.value = 5 >>> tgt.value 5 FNsourceratarget transformt.Iterable[FuncT] | NonerXrxct||||c|_|_|r|\|_|_|dSrz)rrr _transform_transform_invrIr}rrrs rUr~z link.__init__.sL vv&&&#)6  T[  =3< 0DOT0 rTxTc|S)zdefault transform: no-oprS)r}rs rUrzlink._transform7srTc ^ t|jd|jd|t|jd|jd|jd|j|jd|jd|j|jddS#|jd|j|jd|jd|j|jdwxYwNrrrm)setattrrrrrrJ_update_target_update_sourcers rUrIz link.link=s N  A A A A G GHH    KN " "4#6dk!n " M M M KN " "4#6dk!n " M M M M M KN " "4#6dk!n " M M M KN " "4#6dk!n " M M M Ms ACA&D,c#HKd|_ dVd|_dS#d|_wxYwNTFupdatingrs rU_busy_updatingzlink._busy_updatingI9  " EEE!DMMMEDM ! ! ! ! !changecv|jrdS|5t|jd|jd||jt |jd|jd|jkrtd|d ddddS#1swxYwYdS)Nrr Broken link z5: the source value changed while updating the target.) rrrrrnewrrr=r}rs rUrzlink._update_targetQs =  F  " "   DKNDKNDOOFJ4O4O P P Pt{1~t{1~66&*DD a4aaaE                  BB..B25B2cv|jrdS|5t|jd|jd||jt |jd|jd|jkrtd|d ddddS#1swxYwYdS)Nrrrz5: the target value changed while updating the source.) rrrrrrrrr=rs rUrzlink._update_source[s =  F  " "   DKNDKND4G4G 4S4S T T Tt{1~t{1~66&*DD a4aaaE                  rc|jd|j|jd|jd|j|jddSr)r unobserverrrrs rUunlinkz link.unlinkesX A  !4DKN KKK A  !4DKN KKKKKrTrz)rrarrarrrXrx)rrrXrrXrxrXrarrarXrx)rPrQrR__doc__rr~rrrI contextlibcontextmanagerrrrrrSrTrUrIrIs0HSW N N N N N""""LLLLLLrTrIcZeZdZdZdZddd Zdd Zejdd Z ddZ ddZ dS)rGaLink the trait of a source object with traits of target objects. Parameters ---------- source : (object, attribute name) pair target : (object, attribute name) pair transform: callable (optional) Data transformation between source and target. Examples -------- >>> class X(HasTraits): ... value = Int() >>> src = X(value=1) >>> tgt = X(value=42) >>> c = directional_link((src, "value"), (tgt, "value")) Setting source updates target objects: >>> src.value = 5 >>> tgt.value 5 Setting target does not update source object: >>> tgt.value = 6 >>> src.value 5 FNrrarrrXrxc|r|nd|_t||||c|_|_|dS)Nc|SrzrSrs rUz+directional_link.__init__..srT)rrrrrIrs rUr~zdirectional_link.__init__sE'0A))kkvv&&&#)6  T[ rTc  t|jd|jd|t|jd|jd|jd|j|jddS#|jd|j|jdwxYwr)rrrrrrJ_updaters rUrIzdirectional_link.links G  A A A A G GHH    KN " "4ZdRd?ZdMd@Zd S)Sr>z!A base class for all trait types.dict[str, t.Any]metadataFrY allow_none read_only any valuerW info_textra default_valueNr}TraitType[G, S] bool | NonehelprconfigkwargsrXrxc N|tur||_|r||_|||_||nd|_|jr |j|_t |dkrd}tj}|J|j j dkr |dz }|j }|J|j j dk |j dpd} | ddd} d| gt|R} t!| rt#d |d t$| t |jdkr9|j|_|j|n&||_n|j|_| ||jd <| ||jd <dSdS)aKDeclare a traitlet. If *allow_none* is True, None is a valid value in addition to any values that are normally valid. The default is up to the subclass. For most trait types, the default value for ``allow_none`` is False. If *read_only* is True, attempts to directly modify a trait attribute raises a TraitError. If *help* is a string, it documents the attribute's purpose. Extra metadata can be associated with the traitlet using the .tag() convenience method or by using the traitlet instance's .metadata dictionary. Nrrr~rP.z metadata-tagz metadata z was set from the constructor. With traitlets 4.1, metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')r\rr)rBrrrrrrinspect currentframef_codeco_namef_back f_globalsgetsplitsortedrrr^rcopyupdate) r}rrrrrrr]fmodpkgrs rUr~zTraitType.__init__s,  ) )!.D   )(DO  &DN ,DD" 9 %9DL v;;??J$&&A===("j00a H}}}("j00+//*--3C))C##A&C!3888C3 DDDD') 4=!!A%% $ 2 2 4 4  $$V,,,, &  M..00DM  &,DM( #  $(DM& ! ! !  rTrVG | Nonec$|jr|dkrdS|S)a Get a value from a config string such as an environment variable or CLI arguments. Traits can override this method to define their own parsing of config strings. .. seealso:: item_from_string .. versionadded:: 5.0 rxNrr}rVs rU from_stringzTraitType.from_stringRs  ? qF{{4rTrc|jtur|jSt|dr|S|jS)zThe default generator for this trait Notes ----- This method is registered to HasTraits classes during ``class_init`` in the same way that dynamic defaults defined by ``@default`` are. make_dynamic_default)rrBhasattrr rs rUrFzTraitType.defaultbsK  Y . .% % T1 2 2 &,,.. .% %rTc>tdtd|jS)zmDEPRECATED: Retrieve the static default value for this trait. Use self.default_value instead zRget_default_value is deprecated in traitlets 4.0: use the .default_value attributer[r\)rr^rrs rUget_default_valuezTraitType.get_default_valuers/ `     !!rTctdtd|||j}||j|j<|S)z > > > >  s!4AAA// A>=A>cn|jrtd|jz|||dS)zSet the value of the trait by self.name for the instance. Values pass through a validation stage where errors are raised when impropper types, or types that cannot be coerced, are encountered. zThe "%s" trait is read-only.N)rr=rr+rs rU__set__zTraitType.__set__s? > I;diGHH H erTc| |jr|St|dr|||}|jdur|||}|S)NrMF)rr rMr_cross_validaters rUrzTraitType._validates_ =T_=L 4 $ $ .MM#u--E  % . .((e44E rTc,|j|jvr0t|||d}|j|j||}nUt|d|jzr=d|jz}t ||}t ||j|d|||}|S)N)traitrwr _%s_validate use @validate decorator instead.)r_trait_validatorsrr rr __class__)r}rrwproposal meth_namecross_validates rUr/zTraitType._cross_validates 9- - -tecJJKKH4C)$)4S(CCEE S.494 5 5 0&2I$S)44N  2     #N5$//E rTotherTraitType[t.Any, t.Any]rCc|t|trt|g|jSt||gSrzrirC trait_typesr}r9s rU__or__zTraitType.__or__s? eU # # ($3!2344 4$'' 'rTc|jSrz)rrs rUinfozTraitType.infos ~rTerrorException | NonerA t.NoReturnc b||xj|fz c_|jdd|jddD}|Wd|jt d|||jdt d|jd f|_nGd |j||jdt d|jd f|_||j%t ||p|||Md |jt||p|t d|}n>d |j|p|t d|}t |) aRaise a TraitError Parameters ---------- obj : HasTraits or None The instance which owns the trait. If not object is given, then an object agnostic error will be raised. value : any The value that caused the error. error : Exception (default: None) An error that was raised by a child trait. The arguments of this exception should be of the form ``(value, info, *traits)``. Where the ``value`` and ``info`` are the problem value, and string describing the expected value. The ``traits`` are a series of :class:`TraitType` instances that are "children" of this one (the first being the deepest). info : str (default: None) A description of the expected value. By default this is inferred from this trait's ``info`` method. N of c36K|]}td|VdS)aN)r ).0rgs rU z"TraitType.error..(s,#M#MHS!$4$4#M#M#M#M#M#MrTr[zDThe '{}' trait of {} instance contains {} which expected {}, not {}.anrtherz5The '{}' trait contains {} which expected {}, not {}.z2The '{}' trait of {} instance expected {}, not {}.z#The '{}' trait expected {}, not {}.)argsrjoinformatr r=rAr)r}rrwrBrAchainrs rUrBzTraitType.errors@   JJ4' !JJy$ #M#Mejn#M#M#MMM?//5v I$T3//!!JqM$UEJqM:: 00 "EJJSYY I!!JqM$UEJqM:: "EJK 9 UD$7DIIKK>> > ?DKK  # && AA6<< # &&A mmrTrrFc|dkrd}nd}td|ztd|j||S)znDEPRECATED: Get a metadata value. Use .metadata[key] or .metadata.get(key, default) instead. rz3use the instance .help string directly, like x.helpzduse the instance .metadata dictionary directly, like x.metadata[key] or x.metadata.get(key, default)Deprecated in traitlets 4.1, r[r\)rr^rr)r}rrFmsgs rU get_metadatazTraitType.get_metadataTsN &==GCCxC ,s 24FSTUUUU}  g...rTcd|dkrd}nd}td|ztd||j|<dS)z[DEPRECATED: Set a metadata key/value. Use .metadata[key] = value instead. rz;use the instance .help string directly, like x.help = valuezLuse the instance .metadata dictionary directly, like x.metadata[key] = valuerRr[r\N)rr^r)r}rrwrSs rU set_metadatazTraitType.set_metadata`sH &==OCC`C ,s 24FSTUUUU" crTc t|hd}|rtd|ztd|j||S)aSets metadata and returns self. This allows convenient metadata tagging when initializing the trait, such as: Examples -------- >>> Int(0).tag(config=True, sync=True) >rrrrzcThe following attributes are set in using `tag`, but seem to be constructor keywords arguments: %s r[r\)r+keys intersectionr UserWarningrr)r}rmaybe_constructor_keywordss rUtagz TraitType.tagls&)%9%9%F%F @ @ @& & " &  u,-      X&&& rTc*t|jSrz)reprrrs rUdefault_value_reprzTraitType.default_value_reprsD&'''rT)r}rrrarrYrrrrrrarrarXrx)rVrWrXrrz)rrarXr)rXr)rr0rrrXr)rrxrrrXr)rrarrrXr)rr#rrrXr$)rr0rwrrXrx)rrarwrarXr)r9r:rXrCr)NN) rr#rwrarBrCrArrXrD)rrWrFrarXra)rrWrwrarXrx)rrarXr)rPrQrRrrrrrrrBrr~r rFrrrrgoverloadr r+r-rr/r?rArBrTrVr\r_rSrTrUr>r>s\++!#H####JI I    $M$$$$ ) !% B)B)B)B)B)H &&&&& " " " "    %%%%%NZ   Z Z   Z  & & & &????& (((( #' OOOOOb / / / / / # # # #2((((((rTr>c*eZdZdZddZdd Zdd ZdS)_CallbackWrapperzAn object adapting a on_trait_change callback into an observe callback. The comparison operator __eq__ is implemented to enable removal of wrapped callbacks. cbrarXrxc||_t|jtjrdnd}t t |d|z|_|jdkrtddS)Nrz1a trait changed callback must have 0-4 arguments.)rcritypes MethodTyperr nargsr=)r}rcoffsets rUr~z_CallbackWrapper.__init__sf!$'5+;<<C!B*++f4 :>>PQQ Q >rTr9rrYct|trt|j|jkSt|j|kSrz)rirbrYrcr>s rU__eq__z_CallbackWrapper.__eq__sA e- . . *58+,, ,5()) )rTrrc|jdkr|dS|jdkr||jdS|jdkr"||j|jdS|jdkr(||j|j|jdS|jdkr.||j|j|j|jdSdS)Nrrr[rf)rircrroldrrs rUrz_CallbackWrapper.__call__s :?? GGIIIII Z1__ GGFK Z1__ GGFK , , , , , Z1__ GGFKVZ 8 8 8 8 8 Z1__ GGFKVZ F F F F F_rTN)rcrarXrx)r9rrXrYrrrXrx)rPrQrRrr~rlrrSrTrUrbrbsd RRRR**** G G G G G GrTrbrccNt|tr|St|Srz)rirb)rcs rU_callback_wrapperrrs("&''$ ###rTc8eZdZdZdfd Zdfd ZddZxZS)r6zA metaclass for HasDescriptors. This metaclass makes sure that any TraitType class attributes are instantiated and sets their name attribute. mclstype[MetaHasDescriptors]rrWbasestuple[type, ...] classdictrkwdsrarXc  |D]R\}}tj|r9t|tr$t dt d|||<Stj||||fi|S)z Create the HasDescriptors class.Traits should be given as instances, not types (for example, `Int()`, not `Int`). Passing types is deprecated in traitlets 4.1.r[r\) itemsrisclassrkr>rr^super__new__)rtrrvrxrykvr5s rUrzMetaHasDescriptors.__new__sOO%% # #DAqq!! #jI&>&> #E&  !qss ! uwwtT5)DDtDDDrTrxc jtj|||fi|||dS)z-Finish initializing the HasDescriptors class.N)r~r~ setup_class)rrrvrxryr5s rUr~zMetaHasDescriptors.__init__s@ ui884888  """""rTrc^g|_g|_|D]0\}}t|tr|||1t |D]I\}}t|tr/|||j|JdS)zSetup descriptor instance on the class This sets the :attr:`this_class` and :attr:`name` attributes of each BaseDescriptor in the class dict of the newly created ``cls`` before calling their :attr:`class_init` method. N) _descriptorsrr|rirrrrr)rrxrr_s rUrzMetaHasDescriptors.setup_classs+-OO%% % %DAq!^,, % S!$$$sOO + +DAq!^,, +$$$ ''*** + +rT) rtrurrWrvrwrxrryrarXr6) rrWrvrwrxrryrarXrx)rr6rxrrXrx)rPrQrRrrr~r __classcell__r5s@rUr6r6s EEEEEE0######++++++++rTr6c$eZdZdZdfd ZxZS) r7zA metaclass for HasTraits.rrxrrXrxci|_i|_i|_i|_t ||}t|D]} t||}n#t$rY!wxYwt|tr||j|<|}d|z}|} |d| |j dz}n#t$rYnwxYw|D]X}||jvr|j||j|<nL||jdivr|j||j|<nY|jduo|j} t'|t(t*fvr;|j4|j-t|jt0s| r|j|j|<nt'|t2t4fvr;|j4|j-t|jt6s| r|j|j|<nGt'|t8t:fvr,t|jt<s| r|j|j|<nt'|t>t@fvr,t|jtBs| r|j|j|<nt'|tDkr?t|jtBt0t6t<fs| r|j|j|<n^t'|tFkr|j d|j|<n4t|tHr|j%|j&|jr d|j|<|j'|j|<dS)N _%s_defaultr_trait_default_generators)(r_all_trait_default_generators_traits _static_immutable_initial_valuesr~rmrorrrrir>indexrre__dict__rrrrjrr2minmaxintrr*floatrrrYrrArWrrCr1 default_argsdefault_kwargsrF) rrxrrrwr1default_method_name mro_traitcnone_okr5s rUrzMetaHasTraits.setup_classs:<%,.) /1, I&&&ggiiHHG LG LD T**!    %++? L$) D!&3d&:#  #$Ecii0@&A&AA&E$E FII!D#5L5LA*aj88BC*M`Ba9$?qz~~.I2NNNNBCB]^bBc9$?O$1T9Ne>NGU c{22!I-!I-'(;SAA.EL.FKEX|jj}t d|d|dt dtd||||}||S)Nz A parent of z._zA_changed has adopted the new (traitlets 4.1) @observe(change) APIr[r\r)rjrorrr)ridictrr5rPrr^)r}rrorrclsnamers rUcompatible_observerz+observe_compat..compatible_observerws nd + + >**FFn-G {w{{.{{{"     # FtD&!!!rT) r}rarrWrorarrarXra)rB)rrs` rUrKrKis68Ay"""""""* rTrEc|std|D]2}|tur't|tstd|z3t |S)aA decorator to register cross validator of HasTraits object's state when a Trait is set. The handler passed to the decorator must have one ``proposal`` dict argument. The proposal dictionary must hold the following keys: * ``owner`` : the HasTraits instance * ``value`` : the proposed value for the modified trait attribute * ``trait`` : the TraitType instance associated with the attribute Parameters ---------- *names The str names of the Traits to validate. Notes ----- Since the owner has access to the ``HasTraits`` instance via the 'owner' key, the registered cross validator could potentially make changes to attributes of the ``HasTraits`` instance. However, we recommend not to do so. The reason is that the cross-validation of attributes may run in arbitrary order when exiting the ``hold_trait_notifications`` context, and such changes may not commute. z3Please specify at least one trait name to validate.z6trait names to validate must be strings or All, not %r)rsrrirWrE)rmrs rUrMrMsh2 OMNNN]] s??:dC#8#8?TW[[\\ \ 5 ! !!rTrr%cnt|tstd|zt|S)a,A decorator which assigns a dynamic default for a Trait on a HasTraits object. Parameters ---------- name The str name of the Trait on the object whose default should be generated. Notes ----- Unlike observers and validators which are properties of the HasTraits instance, default value generators are class-level properties. Besides, default generators are only invoked if they are registered in subclasses of `this_type`. :: class A(HasTraits): bar = Int() @default('bar') def get_bar_default(self): return 11 class B(A): bar = Float() # This trait ignores the default generator defined in # the base class A class C(B): @default('bar') def some_other_default(self): # This default generator should not be return 3.0 # ignored since it is defined in a # class derived from B.a.this_class. z*Trait name must be a string or All, not %r)rirWrsr%)rs rUrFrFs:H dC MDtKLLL $  rT.)boundcleZdZddZejddZejdd Zdd ZdddZd S)r)rrrXc||_|Srz)r)r}rs rU _init_callzEventHandler._init_calls  rTrMrarcdSrzrS)r}rrMrs rUrzEventHandler.__call__r!rTcdSrzrSr}rMrs rUrzEventHandler.__call__r!rTcVt|dr |j|i|S|j|i|S)zCPass `*args` and `**kwargs` to the handler's function if it exists.r)r rrrs rUrzEventHandler.__call__sB 4  449d-f-- -"4?D3F33 3rTNinstrtypes.MethodType | EventHandlerc>||Stj|j|Srz)rgrhr)r}rrs rUr zEventHandler.__get__s! <K 4000rT)rrrXr))rrrMrarrarXr)rMrarrarXrarz)rrarrarXr)rPrQrRrrgr`rr rSrTrUr)r)sZ   Z Z   Z 44441111111rTr)c eZdZd ddZdd Zd S)r9rrmtuple[Sentinel | str, ...]rjrWrXrxc"||_||_dSrz) trait_namesrj)r}rmrjs rUr~zObserveHandler.__init__s  rTrr0cJ|||j|jdS)Nr)rJrrjr}rs rUrzObserveHandler.instance_inits% T4+$) <<<<>>>>>>>>>rTc,eZdZdZd fd Zd d ZxZS) r/z5The base class for all classes that have descriptors.rMrarrXrctt|j}|tjur ||}n ||g|Ri|}|j|i||Srz)r~r/rrsetup_instance)rrMrnew_methrr5s rUrzHasDescriptors.__new__so--5 v~ % %8C==DD8C1$111&11DT,V,,, rTrxcLd|_|j}|jD] }||dS)zD This is called **before** self.__init__ is called. FN)rr5r)r}rMrrinits rUrzHasDescriptors.setup_instances@ ',#n '  D DJJJJ  rT)rMrarrarXrrMrarrarXrx)rPrQrRrrrrrs@rUr/r/sW??              rTr/) metaclassceZdZUded<ded<ded<ded<ded<ded <ded <dTfd ZdTfd ZdUdZdVdZee j dWdZ e j dWdZ dXdZ dYdZdZd Zd[d&Zd\d(Z d]d^d.Zedfd_d1Zedfd_d2Zefd`d4Zdad7Zdbd9Zdcd;Zeddd@ZededBZedefdC ZdfdDZdfdEZdgdFZ dhdGZ!didIZ"djdJZ#dkdKZ$dldmdOZ%ednfdQ Z&edldodSZ'xZ(S)pr0rrrzdict[str | Sentinel, t.Any]_trait_notifiersr4rYrrrrMrarrXrxc|j|_i|_i|_d|_t t|j|i|dS)NF) rrrrr4rr~r0r)r}rMrr5s rUrzHasTraits.setup_instance7s\"BGGII "!#&+#-i-t>v>>>>>rTc|}i}|rdd}||_d|_i}|D]H\}}||r)t |||t |d||d||<C|||<It |t |jz} | D]R}|j||t||}| |||||d<Sd |_|`| D]}||| tj |i|dS#t$r} d |D} |D]\} } | | d |  d | }t!d ||jj| t(dYd} ~ dSd} ~ wwxYw)NrrrXrxcdSrzrS)rs rUignorez"HasTraits.__init__..ignoreKsrTTrrorrrjrFc,g|]}t|SrS)r^)rIargs rU z&HasTraits.__init__..ms:::$s)):::rT=z, zPassing unrecognized arguments to super({classname}).__init__({arg_s}). {error} This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.)arg_s classnamerBr[r\rp) notify_changerr| has_traitrrr+rr/r set_traitr~r~rsrrNrrOr5rPr^)r}rMr super_args super_kwargsrchangesrrwchangedr arg_s_listrrrr5s rUr~zHasTraits.__init__As~   1    "(D *.D 'G$llnn . . U>>#&& .D#u---#(  !"% $$$GCLL).L%%&kkC $5$55G , , S)99$c@R@RSSsE***&+ U##*/D '" 1 1""73<0000  EGG j 9L 9 9 9 9 9   ::z:::J$**,, 0 01!!Q,,,,////IIj))E NOUf"n5OUOO #            sD88 GB GGc|j}i|d<i|d<|j|d<d|d<|S)Nrr4rFr)rrr)r}ds rU __getstate__zHasTraits.__getstate__~sV M   !# !# !/4466/&+ "#rTstatec||_|j}t|D]M} t ||}t |t r||>#t$rYJwxYwdSrz) rrr5rrrir)rr)r}rrrrws rU __setstate__zHasTraits.__setstate__s  ns88 . .C .S))e\22.''--- "     . .sA.. A;:A;c#bK|jrdVdS d|_dVd|_dS#d|_wxYw)z A contextmanager for running a block with our cross validation lock set to True. At the end of the block, the lock's value is restored to its value prior to entering the block. NTF)rrs rUcross_validation_lockzHasTraits.cross_validation_locksY  & 4 EEE F 4.2+.3+++e+3333s % .c#n K|jrdVdSidd d fd } ||_d |_dVtD]Q}t |j|}||t ||}|||Rn#t$r}d |_ D]b\}}|ddd D]Q}|j dkrD|j tur|||j 7|j |Rci|d}~wwxYw d|_|`D]}|D]}||dS#d|_|`D]}|D]}||wxYw)aHContext manager for bundling trait change notifications and cross validation. Use this when doing multiple trait assignments (init, config), to avoid race conditions in trait notifiers requesting other trait values. All trait notifications will fire after all values have been assigned. N past_changeslist[Bunch] | NonerrrX list[Bunch]c||gS|dddkr|jdkr|j|dd<n|||S)z5Merges the provided change with the last if possible.Nrerjrr)rjrr)rrs rUcompressz4HasTraits.hold_trait_notifications..compresss`'"8O#B'/8;; x@W@W28* R(//%++F333''rTrxcZ|j}|||<dSrz)rr)rrcachers rUholdz0HasTraits.hold_trait_notifications..holds-{&huyy??d rTTcdSrzrSrs rUrz4HasTraits.hold_trait_notifications..strTreF)rrrrrXrrp)rrlistrXrr5r/rr=r|rjrorBrpopvalues) r}rrr1rwrrrrrs @@rUhold_trait_notificationsz"HasTraits.hold_trait_notificationssl  &6 3 EEE F,.E ( ( ( ( @ @ @ @ @ @ @ 3&*".2+ ..00D#DND99E!11$d8K8KLLENN4////0   %3^"%*[[]]==MD'")$$B$-==!;(22%z:: $tVZ @ @ @ @ $ 2 6 6t < < < =  0$/4+& %||~~33G")33**62222333 /4+& %||~~33G")33**6222233s+BB&%E8& D80BD33D88E88:: <!N:  T:..Y&&$$%6r%:%:;;;  A!-.. *JA|,, *1CD!&)) AeHHHH  rThandlert.Callable[..., t.Any]rrjstr | Sentinelc||jvrg}||i|j|<n5||j|vrg}||j||<n|j||}||vr||dSdSrz)rr)r}rrrjnlists rU_add_notifierszHasTraits._add_notifiers*s t, , ,!#E+/-D !$ ' '4066649%d+D11-d3D9 %   LL ! ! ! ! ! rTt.Callable[..., t.Any] | Nonec ||j||=dS|j|||dS#t$rYdSwxYwrz)rremover)r}rrrjs rU_remove_notifierszHasTraits._remove_notifiers9sk )$/555%d+D188AAAAA    DD s<&< A  A NFEventHandler | NoneSentinel | str | Noner ctdtd|t}|r&|t ||dS|t ||dS)aDEPRECATED: Setup a handler to be called when a trait changes. This is used to setup dynamic notifications of trait changes. Static handlers can be created by creating methods on a HasTraits subclass with the naming convention '_[traitname]_changed'. Thus, to create static handler for the trait 'a', create the method _a_changed(self, name, old, new) (fewer arguments can be used, see below). If `remove` is True and `handler` is not specified, all change handlers for the specified name are uninstalled. Parameters ---------- handler : callable, None A callable that is called when a trait changes. Its signature can be handler(), handler(name), handler(name, new), handler(name, old, new), or handler(name, old, new, self). name : list, str, None If None, the handler will apply to all traits. If a list of str, handler will apply to all names in the list. If a str, the handler will apply just to that name. remove : bool If False (the default), then install the handler. If True then unintall it. zCon_trait_change is deprecated in traitlets 4.1: use observe insteadr[r\Nr)rr^rrrrrJ)r}rrr s rUon_trait_changezHasTraits.on_trait_changeDsB Q     <D  A NN,W55TN B B B B B LL*7334L @ @ @ @ @rTrmrncXt|D]}||||dS)a Setup a handler to be called when a trait changes. This is used to setup dynamic notifications of trait changes. Parameters ---------- handler : callable A callable that is called when a trait changes. Its signature should be ``handler(change)``, where ``change`` is a dictionary. The change dictionary at least holds a 'type' key. * ``type``: the type of notification. Other keys may be passed depending on the value of 'type'. In the case where type is 'change', we also have the following keys: * ``owner`` : the HasTraits instance * ``old`` : the old value of the modified trait attribute * ``new`` : the new value of the modified trait attribute * ``name`` : the name of the modified trait attribute. names : list, str, All If names is All, the handler will apply to all traits. If a list of str, handler will apply to all names in the list. If a str, the handler will apply just to that name. type : str, All (default: 'change') The type of notification to filter by. If equal to All, then all notifications are passed to the observe handler. N)rLrr}rrmrjrs rUrJzHasTraits.observeqs@>(.. 5 5D   t 4 4 4 4 5 5rTcXt|D]}||||dS)aRemove a trait change handler. This is used to unregister handlers to trait change notifications. Parameters ---------- handler : callable The callable called when a trait attribute changes. names : list, str, All (default: All) The names of the traits for which the specified handler should be uninstalled. If names is All, the specified handler is uninstalled from the list of notifiers corresponding to all changes. type : str or All (default: 'change') The type of notification to filter by. If All, the specified handler is uninstalled from the list of notifiers corresponding to all types. N)rLr rs rUrzHasTraits.unobserves@,(.. 8 8D  " "7D$ 7 7 7 7 8 8rT str | t.Anyc^|tur i|_dS |j|=dS#t$rYdSwxYw)zRemove trait change handlers of any type for the specified name. If name is not specified, removes all trait notifiers.N)rrrrs rU unobserve_allzHasTraits.unobserve_allsS 3;;$&D ! ! ! )$///    s  ,,t.Callable[..., None]tuple[str | Sentinel, ...]c|D]X}d|z}t||rAt|j|}t|tst ||j|dY|D] }||j|< dS)aSetup a handler to be called when a trait should be cross validated. This is used to setup dynamic notifications for cross-validation. If a validator is already registered for any of the provided names, a TraitError is raised and no new validator is registered. Parameters ---------- handler : callable A callable that is called when the given trait is cross-validated. Its signature is handler(proposal), where proposal is a Bunch (dictionary with attribute access) with the following attributes/keys: * ``owner`` : the HasTraits instance * ``value`` : the proposed value for the modified trait attribute * ``trait`` : the TraitType instance associated with the attribute names : List of strings The names of the traits that should be cross-validated r2r3N)r rr5rirErr4)r}rrmrrrs rUrzHasTraits._register_validators,  D'$.JtZ(( %dnjAA !+??%#":   3 3D+2D "4 ( ( 3 3rTrc |j}d|ji}t|dr |j|d<||t |j|f||_|D]}||dS)z;Dynamically add trait attributes to the HasTraits instance.rQrRN) r5rQr rRrrjrPrr)r}rrattrsr1s rU add_traitszHasTraits.add_traitssns~. 3 ' ' 5$'$4E. ! VclSFE::]]__ & &E    % % % % & &rTrwc|j}||std|jd|t ||||dS)z>Forcibly sets trait attribute, including read-only attributes.Class  does not have a trait named N)r5rr=rPrr+)r}rrwrs rUrzHasTraits.set_traitsfn~~d## YWclWWQUWWXX XTtU+++++rTrrr list[str]c 6t|jdi|S)zGet a list of all the names of this class' traits. This method is just like the :meth:`trait_names` method, but is unbound. rS)r class_traits)rrs rUclass_trait_nameszHasTraits.class_trait_namess&$C$00x00111rT"dict[str, TraitType[t.Any, t.Any]]c `|j}t|dkr|Si}|D]h\}}|D]I\}}t |st |}||j|dsnJ|||<i|S)aGet a ``dict`` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. This method is just like the :meth:`traits` method, but is unbound. The TraitTypes returned don't know anything about the values that the various HasTrait's instances are holding. The metadata kwargs allow functions to be passed in which filter traits based on metadata values. The functions should take a single value as an argument and return a boolean. If any function returns False, then the trait is not included in the output. If a metadata key doesn't exist, None will be passed to the function. rNrrrr|callablervrr)rrrresultrr1 meta_name meta_evals rUr!zHasTraits.class_traitss"!!## x==A  M!<<>> % %KD%(0(8(8 % %$ 9 **7 +I 6 6I y!3!3It!D!DEEE %t  rTc |t||fd|jdi|DS)zGet a dict of all the traitlets defined on this class, not a parent. Works like `class_traits`, except for excluding traits from parents. cBi|]\}}t|d|u||Srzr)rIrtrgsups rU z.HasTraits.class_own_traits.."@   AsAt$$A-- q---rTrS)r~r!r|)rrr-r5s @rUclass_own_traitszHasTraits.class_own_traitss]Coo    *#*66X66<<>>    rTc||jvS)z?Returns True if the object has a trait with the specified name.)rrs rUrzHasTraits.has_trait(st|##rTc||jvS)a)Returns True if the specified trait has a value. This will return false even if ``getattr`` would return a dynamically generated default value. These default values will be recognized as existing only after they have been generated. Example .. code-block:: python class MyClass(HasTraits): i = Int() mc = MyClass() assert not mc.trait_has_value("i") mc.i # generates a default value assert mc.trait_has_value("i") )rrs rUtrait_has_valuezHasTraits.trait_has_value,s*t)))rTc 6fdjdi|DS)aA ``dict`` of trait names and their values. The metadata kwargs allow functions to be passed in which filter traits based on metadata values. The functions should take a single value as an argument and return a boolean. If any function returns False, then the trait is not included in the output. If a metadata key doesn't exist, None will be passed to the function. Returns ------- A ``dict`` of trait names and their values. Notes ----- Trait values are retrieved via ``getattr``, any exceptions raised by traits or the operations they may trigger will result in the absence of a trait value in the result ``dict``. c2i|]}|t|SrSr,)rIrr}s rUr.z*HasTraits.trait_values..Ws%SSSdgdD))SSSrTrSrr}rs` rU trait_valueszHasTraits.trait_valuesCs4(TSSS6Fd6F6R6R6R6RSSSSrTcd|z}||jvrt||S||jjvrt|j|S|j|S)zReturn default generator for a given trait Walk the MRO to resolve the correct default generator according to inheritance. r)rrr5r)r}r method_names rU_get_trait_default_generatorz&HasTraits._get_trait_default_generatorYs[ $d* $- ' '4-- - $.1 1 14>;77 71$77rTdict[str, t.Any] | Sentinelc |D]?}||s(td|dt|jd@t |dkr7t |dkr$||d|S|jdi|}||i}|D]#}|||||<$|S)zReturn a trait's default value or a dictionary of them Notes ----- Dynamically generated default values may depend on the current state of the object.'z' is not a trait of 'z ' instancesrrrS)rr=rjrPrr:rr)r}rmrrtrdefaultss rUrzHasTraits.trait_defaultses _ _A>>!$$ _ !]Q!]!]T$ZZ=P!]!]!]^^^ _ u::??s8}}11>444U1X>>tDD D&d&2222 5!!! E EA>$;;A>>tDDHQKKrTc 6t|jdi|S)z2Get a list of all the names of this class' traits.rS)rrr6s rUrzHasTraits.trait_names{s"KDK++(++,,,rTc `|j}t|dkr|Si}|D]h\}}|D]I\}}t |st |}||j|dsnJ|||<i|S)aGet a ``dict`` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. The TraitTypes returned don't know anything about the values that the various HasTrait's instances are holding. The metadata kwargs allow functions to be passed in which filter traits based on metadata values. The functions should take a single value as an argument and return a boolean. If any function returns False, then the trait is not included in the output. If a metadata key doesn't exist, None will be passed to the function. rNr%)r}rrr'rr1r(r)s rUrzHasTraits.traitss""$$ x==A  M!<<>> % %KD%(0(8(8 % %$ 9 **7 +I 6 6I y!3!3It!D!DEEE %t  rT traitnamerrFcf t|j|}n2#t$r%}td|jjd||d}~wwxYwd|zdz}t ||r6|t||vr$t||||S|j||S)z%Get metadata values for trait by key.rrNr _metadata)rr5rr=rPr rr)r}rArrFr1r metadata_names rUtrait_metadatazHasTraits.trait_metadatas DNI66EE   Z0ZZyZZ  i+5 4 ' ' 4C743O3O,O,O4//33CAA A>%%c733 3s A AAdict[str, EventHandler]ct||fd||DS)zGet a dict of all event handlers defined on this class, not a parent. Works like ``event_handlers``, except for excluding traits from parents. cBi|]\}}t|d|u||Srzr,)rIrtrr-s rUr.z4HasTraits.class_own_trait_events..r/rT)r~eventsr|)rrr-r5s @rUclass_own_trait_eventsz HasTraits.class_own_trait_eventssV Coo    **T**0022    rTrci}t|D]X\}}t|tr>||||<"||jvr|||<1t |dr|jdi|jr|||<Y|S)aGet a ``dict`` of all the event handlers of this class. Parameters ---------- name : str (default: None) The name of a trait of this class. If name is ``None`` then all the event handlers of this class will be returned instead. Returns ------- The event handlers associated with a trait name, or all event handlers. NtagsrS)rrir)rr rL)rrrIrrs rU trait_eventszHasTraits.trait_eventsssOO & &DAq!\** &< !F1IIQ]** !F1IIQ''&&s0000&$%q  rTr)rXr)rrrXrxr)rrWr)rar(rarXrxrp)rrrXrx)rrrrrjrrXrx)rrrrrjrrXrx)NNF)rr rr r rYrXrx)rrrmrnrjrrXrx)rrrXrx)rrrmrrXrx)rrarXrx)rrWrwrarXrx)rrrrarXr)rrrrarXr#)rrWrXrY)rrarXr)rrWrXra)rmrWrrarXr;)rrarXr)rrarXr#rz)rArWrrWrFrarXra)rrrrWrXrF)rrrrrXrF))rPrQrRrrr~rrpropertyrrrrr'rrrr rrrJrrrrr classmethodr"r!r0rr3r7r:rrrrErJrMrrs@rUr0r0.s####666611112222    3333??????;;;;;;z    ...."444X4$>3>3>3>3@     ....))))V " " " "    (,&* +A+A+A+A+A`>A' 5 5 5 5 5J>A' 88888214     "3"3"3"3H & & & &,,,,222[2[B      [  $$$$****.TTTT, 8 8 8 8,----> 4 4 4 4 4      [  [rTr0ceZdZdZddZdS) r"ze A trait with error reporting and string -> type resolution for Type, Instance and This. stringrWrXrac t|S)zM Resolve a string supplied for a type into an actual object. r )r}rQs rU_resolve_stringz#ClassBasedTraitType._resolve_strings6"""rTNrQrWrXrarPrQrRrrSrSrTrUr"r"s2 ######rTr"c(eZdZdZejr`ej d,d-dZej d,d.dZej d,d/dZej d,d0dZedd dddfd1fd" Zd2d&Z d3d(Z d4d)Z d5d*Z d3d+Z xZS)6r@zt|trH ||}n1#t$r$}t d|jd|d|d|d}~wwxYw t ||jr|Sn#t$rYnwxYw| ||dS)z4Validates that the value is a valid object instance.zThe ' ' trait of z instance must be a type, but z could not be importedN) rirWrS ImportErrorr=rrkrYrrBr}rrwrs rUrMz Type.validate_s eS ! !  ,,U33    7DI77#77777   %,,       D  3s&- AAAA77 BBrWct|jtr|j}n|jjdz|jjz}d|z}|jr|dzS|S)#Returns a description of the trait.rza subclass of '%s' or None)rirYrWrQrPr)r}rYr's rUrAz Type.infoqs] dj# & & FJEEJ)C/$*2EEE%- ? 'J& & rTc.|dSrz_resolve_classesrs rUrzType.instance_init| rTct|jtr||j|_t|jtr!||j|_dSdSrz)rirYrWrSrrs rUrszType._resolve_classessn dj# & & :--dj99DJ d(# . . J!%!5!5d6H!I!ID    J JrTc|j}|Jt|trt|St|jd|jS)Nr)rrirWr^rQrPr|s rUr_zType.default_value_reprsV"   eS ! ! @;; 5+>>en>>?? ?rT......)r}rWrrXrYrZrr[rrrrrr\rrarXrx)r}r`rrXrYrZrrarrrrrr\rrarXrx)r}rcrrrYrrr[rrrrrr\rrarXrx)r}rerrfrYrrrarrrrrr\rrarXrx)rrarYrarrYrrrrrr\rrarXrxrrarwrarXrrrr)rPrQrRrrg TYPE_CHECKINGr`r~rBrMrArrsr_rrs@rUr@r@sFF4 47 #),%("#&       47 #(+%("#&        #),%("#&       '*(+%("#&       ) !%#: : : : : : : x$        JJJJ @@@@@@@@rTr@cHeZdZUdZdZded<ejr`ej d.d/dZ ej d.d0dZ ej d.d1dZ ej d.d2dZ d3d4fd! Z d5d%Z d6d'Z d7d(Z d8d)Z d9d*Zd6d+Zd:d-ZxZS);r1zA trait whose value must be an instance of a specified class. The value can also be an instance of a subclass of the specified class. Subclasses can declare default classes by overriding the klass attribute Nstr | type[T] | NonerY.r} Instance[T]type[T]rMtuple[t.Any, ...] | Nonekwdict[str, t.Any] | Nonerr[rrrrrrarXrxc dSrzrSr}rYrMrrrrrs rUr~zInstance.__init__r_rTInstance[T | None]rac dSrzrSrs rUr~zInstance.__init__r_rTInstance[t.Any]c dSrzrSrs rUr~zInstance.__init__r_rTInstance[t.Any | None]c dSrzrSrs rUr~zInstance.__init__r_rTFrYc ||j}|1tj|st|tr||_nt d|z|$t|t st d|$t|tst d||_||_ tj d|||d|dS)aConstruct an Instance trait. This trait allows values that are instances of a particular class or its subclasses. Our implementation is quite different from that of enthough.traits as we don't allow instances to be used for klass and we handle the ``args`` and ``kw`` arguments differently. Parameters ---------- klass : class, str The class that forms the basis for the trait. Class names can also be specified as strings, like 'foo.bar.Bar'. args : tuple Positional arguments for generating the default value. kw : dict Keyword arguments for generating the default value. allow_none : bool [ default False ] Indicates whether None is allowed as a value. **kwargs Extra kwargs passed to `ClassBasedTraitType` Notes ----- If both ``args`` and ``kw`` are None, then the default value is None. If ``args`` is a tuple and ``kw`` is a dict, then the default is created as ``klass(*args, **kw)``. If exactly one of ``args`` or ``kw`` is None, the None is replaced by ``()`` or ``{}``, respectively. Nz+The klass attribute must be a class not: %rz)The 'kw' argument must be a dict or None.z,The 'args' argument must be a tuple or None.)rrrrS) rYrr}rirWr=rtuplerrr~r~) r}rYrMrrrrrr5s rUr~zInstance.__init__sL =JE  GOE$:$: jPS>T>T DJJJURSS S NJr4$8$8NHII I  ju&=&= KLL L  YJ)$YYRXYYYYYrTrrwT | Nonec|jJ|jr||St||jr|S|||dSrz)rYrrirBrs rUrMzInstance.validate sVz%%% ? u}L eTZ ( ( #L JJsE " " " " "rTrWct|jtrt|j}nt d|j}|jr|dz }|S)NrHrp)rirYrWrr r)r}r's rUrAz Instance.info sQ dj# & & / ,,FFc4:..F ? ! j F rTc.|dSrzrrrs rUrzInstance.instance_init rtrTc|t|jtr!||j|_dSdSrz)rirYrWrSrs rUrszInstance._resolve_classes s; dj# & & :--dj99DJJJ : :rTcj|j |jdS|jJ|j|jpdi|jpiS)NrS)rrrYrs rUr zInstance.make_dynamic_default# sN   %D,?,G4z%%%tzD-3T9L9RPRTTTrTcDt|Srz)r^r rs rUr_zInstance.default_value_repr) sD--//000rTrVc t|Srz)rfrs rUr zInstance.from_string, s!!$$$rTrw)r}r|rYr}rMr~rrrr[rrrrrrarXrx)r}rrYr}rMr~rrrrarrrrrrarXrx)r}rrYrrMr~rrrr[rrrrrrarXrx)r}rrYrrMr~rrrrarrrrrrarXrx)NNNFNN)rYr{rMr~rrrrYrrrrrrarXrxrrarwrarXrrrr)rXrrVrWrXr)rPrQrRrrYrrgryr`r~rMrArrsr r_r rrs@rUr1r1s#'E&&&&4 !-0*-),%("       !-0*-(+%("       !$-0*-),%("       !$-0*-(+%("      '+)-&* !%6Z6Z6Z6Z6Z6Z6Zp####    ::::UUUU 1111%%%%%%%%rTr1ceZdZdZddZdS) r,zC Mixin for forward-declared versions of Instance and Type. rQrWrXracb|jj}td||gS)z Find the specified class name by looking for it in the module in which our this_class attribute was defined. r)rrQr rN)r}rQmodnames rUrSz$ForwardDeclaredMixin._resolve_string5 s- /,388Wf$566777rTNrTrUrSrTrUr,r,0 s2888888rTr,ceZdZdZdS)r-z+ Forward-declared version of Type. NrPrQrRrrSrTrUr-r-> rTr-ceZdZdZdS)r+z/ Forward-declared version of Instance. NrrSrTrUr+r+D rrTr+c0eZdZdZdZd fd Zd d ZxZS)r<aA trait for instances of the class containing this trait. Because how how and when class bodies are executed, the ``This`` trait can only have a default value of None. This, and because we always validate default values, ``allow_none`` is *always* true. z4an instance of the same type as the receiver or NonerrarXrxc :tjdi|dS)Nrzr~r~)r}rr5s rUr~z This.__init__T s&(((((((rTrrwr#cv|jJt||js||S|||dSrz)rrirBrs rUrMz This.validateW sI*** eT_ - - #%-L JJsE " " " " "rT)rrarXrx)rrarwrarXr#)rPrQrRrrr~rMrrs@rUr<r<J scGI))))))########rTr<cbeZdZdZdfd Zddfd Zdfd ZddZddZddZ d fd Z xZ S)!rCz'A trait type representing a Union type.r=rarrXrxc t||_dd|jD|_t jdi|dS)aConstruct a Union trait. This trait allows values that are allowed by at least one of the specified trait types. A Union traitlet cannot have metadata on its own, besides the metadata of the listed types. Parameters ---------- trait_types : sequence The list of trait types of length at least 1. **kwargs Extra kwargs passed to `TraitType` Notes ----- Union([Float(), Bool(), Int()]) attempts to validate the provided values with the validation function of Float, then Bool, and finally Int. Parsing from string is ambiguous for container types which accept other collection-like literals (e.g. List accepting both `[]` and `()` precludes Union from ever parsing ``Union([List(), Tuple()])`` as a tuple; you can modify behaviour of too permissive container traits by overriding ``_literal_from_string_pairs`` in subclasses. Similarly, parsing unions of numeric types is only unambiguous if types are provided in order of increasing permissiveness, e.g. ``Union([Int(), Float()])`` (since floats accept integer-looking values). z or c6g|]}|SrS)rA)rItts rUrz"Union.__init__.. s %K%K%KBbggii%K%K%KrTNrS)rr=rNrr~r~)r}r=rr5s rUr~zUnion.__init__e s]8 ,,%K%K$:J%K%K%KLL""6"""""rTNrct|}|jD]!}|tur||}!|Srz)r~rFr=rB)r}rrFr1r5s rUrFz Union.default sP''//#&&%  E)##--,,rTrrrrct|jD]}||dt||dSrz)reversedr=rr~)r}rr trait_typer5s rUrzUnion.class_init sV"4#344 - -J  ! !#t , , , , 3%%%%%rTrc^t|jD]}||dSrz)rr=r)r}rrs rUrzUnion.subclass_init s="4#344 * *J  $ $S ) ) ) ) * *rTrwcB|j5|jD]`} |||}|j!t |d|jzdz|j|ccdddS#t $rY]wxYw dddn #1swxYwY|||dS)NrrC)rr=rrrrr=rB)r}rrwrrs rUrMzUnion.validate s&  &  ".   ",,S%88Ay,S49_{%BJDWXXXHH        "H                 3s4 A>?A!A>! A.+A>-A..A>>BBr9ct|trt|j|jzStg|j|Srzr<r>s rUr?z Union.__or__ sI eU # # 5)E,==>> >34+3U344 4rTrVrWc|jD]F} ||}|d|cS#ttf$rYCwxYwt |Srz)r=r rMr=rer~)r}rVrrr5s rUr zUnion.from_string s*  J **1--!**433333 +    ww""1%%%s*9A  A )r=rarrarXrxrz)rrarXrarrrrXrxrrarwrarXra)r9rarXrCrVrWrXra) rPrQrRrr~rFrrrMr?r rrs@rUrCrCb s11######@&&&&&& ****    5555 &&&&&&&&&&rTrCc6eZdZUdZejr{ej d'ddddd(dZej d'ddddd)dZej d'dddddd*dZ d'dddddd+dZejd,d Zejd-d!Zd.d#ZdZ de d<d$Z d%Z d/d&Z dS)0rzA trait which allows any value..rrrr}rrarr[rrrrrr\rrXrxc dSrzrSr}rrrrrrs rUr~z Any.__init__ r_rTrac dSrzrSrs rUr~z Any.__init__ r_rTFN)rrrrLiteral[True, False]c dSrzrSr}rrrrrrs rUr~z Any.__init__ r_rTrrYc dSrzrSrs rUr~z Any.__init__  CrTrrrcdSrzrSrs rUr z Any.__get__  CrTcdSrzrSrs rUr z Any.__get__ rrT t.Any | AnycdSrzrSrs rUr z Any.__get__ s CrTTrcdSrzrSrs rUrzAny.subclass_init  rT).)r}rrrarr[rrrrrr\rrarXrx)r}rrrarrarrrrrr\rrarXrx)r}rrrarrrrrrrrarrarXrx)r}rrrarrYrrrrrrarrarXrx)rrxrrrXr)rrarrrXra)rr\rrrXrr)rPrQrRrrgryr`r~r rrrrrrSrTrUrr s))> $'  &)"#&        $'  &)"#&        $' 03"%*        $'  %!%*                       #'M&&&&JI      rTrr1'Int[t.Any, t.Any] | Float[t.Any, t.Any]rrwc |j>||jkr3td|jdt|d|jd|d |j>||jkr3td|jdt|d|jd|d |S)z Validate that a number to be applied to a trait is between bounds. If value is not between min_bound and max_bound, this raises a TraitError with an error message appropriate for this trait. NzThe value of the 'rkz" instance should not be less than , but a value of z was specifiedz% instance should not be greater than )rr=rrr)r1rrws rU_validate_boundsr s y!2!2       %   |jr|dkrdSt|SNrx)rrrs rUr zInt.from_stringa s$ ? qF{{41vv rTrrcdSrzrSrs rUrzInt.subclass_initf rrT.....)r}rrrrr[rrrrrr\rrarXrx)r}rrrrrarrrrrr\rrarXrx)rrarrYrrrrrr\rrarXrxrxrVrWrXrrrPrQrRrrrrgr`r~rBrMr rrrs@rUr2r2! s MIZ),%(!$"     Z  Z03$'!$"     Z   ) !%#        ( 2 2 2 2         rTr2ceZdZdZejr8ej dd dZej dd!dZ dd"dZd#dZdS)$rz#A casting version of the int trait..r}CInt[int, t.Any]rt.Any | Sentinelrr[rrrrrr\rrarXrxc dSrzrSrs rUr~z CInt.__init__o rrTCInt[int | None, t.Any]t.Any | Sentinel | Nonerac dSrzrSrs rUr~z CInt.__init__{ rrTrYc dSrzrSrs rUr~z CInt.__init__  CrTrrwrc t|}n&#t$r|||YnwxYwt|||Srz)rrrBrrs rUrMz CInt.validate s[ #JJEE # # # JJsE " " " " " #c5111  55Nr)r}rrrrr[rrrrrr\rrarXrx)r}rrrrrarrrrrr\rrarXrx)r}rrrrrYrrrrrr\rrarXrxrx rPrQrRrrgryr`r~rMrSrTrUrrj s--# /2),%("#&       69(+%("#&      69"%("#&     222222rTrceZdZdZdZdZej d(d)dZej d(d*dZe ddddfd+fd Zd,d!Z d-d$Z d.d'Z xZ S)/r*zA float trait.gza float.r}Float[float, int | float]rfloat | Sentinelrr[rrrrrr\rrarXrxc dSrzrSrs rUr~zFloat.__init__ rrT%Float[int | None, int | float | None]float | Sentinel | Nonerac dSrzrSrs rUr~zFloat.__init__ rrTFNrYc |dtd |_|dtd|_t jd|||||d|dS)NrinfrrrS)rrrrr~r~rs rUr~zFloat.__init__ s::eeEll]33::eU5\\22 '!         rTrrwrct|trt|}t|ts|||t |||Srz)rirrrBrrs rUrMzFloat.validate sW eS ! ! !%LLE%'' # JJsE " " "c5111rTrVrWc>|jr|dkrdSt|Sr)rrrs rUr zFloat.from_string s$ ? qF{{4QxxrTrrcdSrzrSrs rUrzFloat.subclass_init rrTr)r}rrrrr[rrrrrr\rrarXrx)r}rrrrrarrrrrr\rrarXrx)r}rrrrrYrrrrrr\rrarXrxrxrrrrs@rUr*r* s MIZ+.%(!$"     Z  Z25$'!$"     Z  2; !&#        (2222         rTr*ceZdZdZejr8ej dddZej dddZ dd dZd!dZdS)"rz%A casting version of the float trait..r}CFloat[float, t.Any]rrarr[rrrrrr\rrXrxc dSrzrSrs rUr~zCFloat.__init__ rrTCFloat[float | None, t.Any]rac dSrzrSrs rUr~zCFloat.__init__ rrTrYc dSrzrSrs rUr~zCFloat.__init__ rrTrrwrc t|}n&#t$r|||YnwxYwt|||Srz)rrrBrrs rUrMzCFloat.validate s[ #%LLEE # # # JJsE " " " " " #c5111rNr)r}rrrarr[rrrrrr\rrarXrx)r}rrrarrarrrrrr\rrarXrx)r}rrrarrYrrrrrr\rrarXrxrxrrSrTrUrr s//# $'),%("#&       $'(+%("#&      $'"%("#&     222222rTrc2eZdZdZdZdZdd Zdd ZddZdS)r#zA trait for complex numbers.yza complex numberrrarwrXcomplex | Nonect|tr|St|ttfrt|S|||dSrz)ricomplexrrrBrs rUrMzComplex.validate sU eW % % L eeS\ * * "5>> ! 3rTrVrWc>|jr|dkrdSt|Sr)rrrs rUr zComplex.from_string s% ? qF{{4qzzrTrrrxcdSrzrSrs rUrzComplex.subclass_init" rrTNrrarwrarXr)rVrWrXrr rPrQrRrrrrMr rrSrTrUr#r# s`&&M"I       rTr#ceZdZdZd dZdS) rz.A casting version of the complex number trait.rrarwrXrcp t|S#t$r|||YdSwxYwrz)rrrBrs rUrMzCComplex.validate) sK #5>> ! # # # JJsE " " " " " " #  55NrrPrQrRrrMrSrTrUrr& s.88######rTrc2eZdZdZdZdZdd Zdd ZddZdS)rzA trait for byte strings.rTza bytes objectrrarwrX bytes | Nonec`t|tr|S|||dSrz)ribytesrBrs rUrMzBytes.validate9 s3 eU # # L 3rTrVrWc |jr|dkrdSt|dkrNdD]K}|ddd|kr8|d|kr,|}|dd}td|d|d td nL|d S) Nrxrn"r=r[brezISupporting extra quotes around Bytes is deprecated in traitlets 5.0. Use instead of rr\utf8)rrrr^encode)r}rVquoteold_ss rUr zBytes.from_string> s ? qF{{4 q66Q;;#  RaR5KKK''AbEUNNE!B$A; ;;05;;;*#$  ExxrTrrrxcdSrzrSrs rUrzBytes.subclass_initP rrTNrrarwrarXr)rVrWrXrrrrSrTrUrr3 s`##M I     $      rTrceZdZdZd dZdS) rz+A casting version of the byte string trait.rrarwrXrcp t|S#t$r|||YdSwxYwrz)rrrBrs rUrMzCBytes.validateW sK #<<  # # # JJsE " " " " " " #rNrrrSrTrUrrT s.55######rTrceZdZdZdZdZejr8ej d&d'dZ ej d&d(dZ d&d)dZ d*dZ d+d!Z d,d$Z d%S)-rAzA trait for unicode strings.rza unicode string.r}Unicode[str, str | bytes]rrrr[rrrrrrarrXrxc dSrzrSrs rUr~zUnicode.__init__f rrT'Unicode[str | None, str | bytes | None]str | Sentinel | Nonerac dSrzrSrs rUr~zUnicode.__init__r rrTrYc dSrzrSrs rUr~zUnicode.__init__~ rrTrrwrc Nt|tr|St|trb |ddS#t$r>}d}t |||jt||d}~wwxYw| ||dS)Nasciistrictz=5.r\)rospath expanduserrrr^)r}rVrrs rUr zUnicode.from_string s ? qF{{4 G  q ! ! q66Q;;  Q41R5%%%%A%%%%%E!B$A`'(``8=```*#$  rTrrcdSrzrSrs rUrzUnicode.subclass_init rrTNr)r}rrrrr[rrrrrrarrarXrx)r}rrrrrarrrrrrarrarXrx)r}rrrrrYrrrrrrarrarXrxrxrr) rPrQrRrrrrgryr`r~rMr rrSrTrUrArA^ s&&M"I# -0),%("       47(+%("      47"%("         $      rTrAceZdZdZejr8ej dddZej dd dZ dd!dZd"dZdS)#rz'A casting version of the unicode trait..r}CUnicode[str, t.Any]rrrr[rrrrrrarrXrxc dSrzrSrs rUr~zCUnicode.__init__ rrTCUnicode[str | None, t.Any]rrac dSrzrSrs rUr~zCUnicode.__init__ rrTrYc dSrzrSrs rUr~zCUnicode.__init__ rrTrrwrcp t|S#t$r|||YdSwxYwrz)rWrrBrs rUrMzCUnicode.validate sK #u::  # # # JJsE " " " " " " #rNr)r}r'rrrr[rrrrrrarrarXrx)r}r)rrrrarrrrrrarrarXrx)r}r)rrrrYrrrrrrarrarXrxrxrrSrTrUrr s11# -0),%("       47(+%("      47"%("     ######rTrc>eZdZdZdZedZdd Zdd Zd S)r8z{A string holding a valid object name in this version of Python. This does not check that the name exists in any scope.z#a valid object identifier in Pythonc|SrzrS)rrVs rUrzObjectName. s1rTrrarwrXrWc|||}t|tr|r|S|||dSrz) coerce_strrirWr_rBrs rUrMzObjectName.validate sYU++ eS ! ! e&8&8&:&: L 3rTrVrc$|jr|dkrdS|Srrrs rUr zObjectName.from_string s ? qF{{4rTNrrarwrarXrW)rVrWrXr) rPrQrRrr staticmethodr0rMr rSrTrUr8r8 s^>>6Inn--JrTr8ceZdZdZd dZdS) r'zFA string holding a valid dotted object name in Python, such as A.b3._crrarwrXrWc|||}t|tr.td|dDr|S|||dS)Nc3>K|]}|VdSrz)r_)rIrHs rUrJz,DottedObjectName.validate.. s,)U)Uq!..*:*:)U)U)U)U)U)UrTr)r0rirWallrrBrs rUrMzDottedObjectName.validate sqU++ eS ! ! c)U)UEKKPSDTDT)U)U)U&U&U L 3rTNr2rrSrTrUr'r' s.PPrTr'ceZdZdZdZdZejr8ej d(d)dZ ej d(d*dZ d(d+dZ d,dZ d-d!Z d.d$Z d/d&Z d'S)0rzA boolean (True, False) trait.Fz a boolean.r}Bool[bool, bool | int]rbool | Sentinelrr[rrrrrrarrXrxc dSrzrSrs rUr~z Bool.__init__ rrT$Bool[bool | None, bool | int | None]bool | Sentinel | Nonerac dSrzrSrs rUr~z Bool.__init__ rrTrYc dSrzrSrs rUr~z Bool.__init__ rrTrrwrct|tr|St|tr|dkrdS|dkrdS|||dS)NrTrF)rirYrrBrs rUrMz Bool.validate% sa eT " " L s # # zzt!u 3rTrVrWc~|jr|dkrdS|}|dvrdS|dvrdStd)Nrx>1trueT>0falseFz%r is not 1, 0, true, or false)rlowerrers rUr zBool.from_string/ sU ? qF{{4 GGII  4 . 5=>> >rTrrcdSrzrSrs rUrzBool.subclass_init: rrTrc Fgd}|jr|d|S) Completion hints for argcomplete)rCrBrErDrx)rr)r}r completionss rU argcompleterzBool.argcompleter= s1111 ? '   v & & &rTNr)r}r9rr:rr[rrrrrrarrarXrx)r}r<rr=rrarrrrrrarrarXrx)r}r<rr=rrYrrrrrrarrarXrxrxrrrrarXr)rPrQrRrrrrgryr`r~rMr rrKrSrTrUrr s((MI# .1),%("       58(+%("      58"%("      ? ? ? ?    rTrceZdZdZejr8ej dddZej dd dZ dd!dZd"dZdS)#rz'A casting version of the boolean trait..r}CBool[bool, t.Any]rr:rr[rrrrrrarrXrxc dSrzrSrs rUr~zCBool.__init__J rrTCBool[bool | None, t.Any]r=rac dSrzrSrs rUr~zCBool.__init__V rrTrYc dSrzrSrs rUr~zCBool.__init__b rrTrrwrcp t|S#t$r|||YdSwxYwrz)rYrrBrs rUrMzCBool.validatem sK #;;  # # # JJsE " " " " " " #rNr)r}rNrr:rr[rrrrrrarrarXrx)r}rPrr=rrarrrrrrarrarXrx)r}rPrr=rrYrrrrrrarrarXrxrxrrSrTrUrrE s11# .1),%("       58(+%("      58"%("     ######rTrceZdZdZejr.ej d/d0dZej d/d1dZeddddfd2fd Zd3d!Z d4d5d$Z d4d5d%Z d6d&Z d6d'Z d7d)Zd8d,Zd9d.ZxZS):r(z0An enum whose value must be in a given sequence..r}Enum[G]r t.Sequence[G]r G | Sentinelrr[rrrrrrarrXrxc dSrzrSr}rrrrrrrs rUr~z Enum.__init__y r_rTEnum[G | None]t.Sequence[G] | NoneG | Sentinel | Nonerac dSrzrSrYs rUr~z Enum.__init__ r_rTFNrYc ||_|dur |turd}||d<||d<||d<||d<tj|fi|dS)NTrrrr)rrBr~r~) r}rrrrrrrr5s rUr~z Enum.__init__ sr   -9"<"< M)|'{v!x11&11111rTrrwrcV|jr ||jvr|S|||dSrz)rrBrs rUrMz Enum.validate s7 ; 5DK//L 3rTas_rstrWc|jpg}|r dd|D}ntt|}|S)6Returns a description of the trait choices (not none).|c3 K|] }d|zV dSz``%r``NrSrIrs rUrJz$Enum._choices_str.. s&!@!@1(Q,!@!@!@!@!@!@rT)rrNr^r)r}r`choices choice_strs rU _choices_strzEnum._choices_str sQ+#  -!@!@!@!@!@@@JJd7mm,,JrTcZ|jr d|rdndznd}d|||Sro or %s`None`rxrany of rrir}r`nones rU_infoz Enum._info C>BoUxv9886::SU:**622:D:::rTc.|dSNFr`rrrs rUrAz Enum.info zzz'''rTc.|dSNTrvrwrs rUinfo_rstz Enum.info_rst zzz&&&rTrVcn |d|S#t$rt|cYSwxYwrz)rMr=rfrs rUr zEnum.from_string sJ )==q)) ) ) ) )%a(( ( ( ( )s 44rrcdSrzrSrs rUrzEnum.subclass_init rrTrc (d|jpgDS)rIc,g|]}t|SrS)rW)rIrs rUrz%Enum.argcompleter.. s2221A222rT)r)r}rs rUrKzEnum.argcompleter s22 1r2222rTr)r}rUrrVrrWrr[rrrrrrarrarXrx)r}rZrr[rr\rrarrrrrrarrarXrx)r}rUrr[rr\rrYrrrrrrarrarXrxrxFr`rYrXrWrrrrL)rPrQrRrrgryr`r~rBrMrirrrAr{r rrKrrs@rUr(r(t s{:: +.),%("       25(+%("      .7 !%2222222& ;;;;; ((((''''))))     33333333rTr(cJeZdZdZefdfd ZddZdddZddZddZ xZ S)r!z4An enum of strings where the case should be ignored.r}CaselessStrEnum[t.Any]rrarrrXrxc @tj|fd|i|dSNrr)r}rrrr5s rUr~zCaselessStrEnum.__init__ s/ GG}GGGGGGrTrrwrc*t|ts||||jpgD]G}t|tsJ||kr|cSH|||dSrz)rirWrBrrF)r}rrwrs rUrMzCaselessStrEnum.validate s%%% # JJsE " " ""  Aa%% % %%wwyyEKKMM))* 3rTFr`rYrWc\|jr d|rdndznd}d||d|S)rorlrmrxrrnz (case-insensitive)rorps rUrrzCaselessStrEnum._info sF>BoUxv9886::SUM**622MMtMMMrTc.|dSrurwrs rUrAzCaselessStrEnum.info rxrTc.|dSrzrwrs rUr{zCaselessStrEnum.info_rst r|rT) r}rrrarrarrarXrxrxrrr) rPrQrRrrBr~rMrrrAr{rrs@rUr!r! s>> )HHHHHHHNNNNN ((((''''''''rTr!cVeZdZdZdZdZeddfdfd ZddZdddZ ddZ ddZ xZ S)r.zEAn case-ignoring enum matching choices by unique prefixes/substrings.Fr}FuzzyEnum[t.Any]rrarcase_sensitiverYsubstring_matchingrrXrxc \||_||_tj|fd|i|dSr)rrr~r~)r}rrrrrr5s rUr~zFuzzyEnum.__init__ s?-"4GG}GGGGGGrTrrwrcl tts|||jrdnd|j}|rdnd |jpg} fd|D}t |dkrt||D] \}}|r|cS ||dS)Nc|SrzrSrs rUrz$FuzzyEnum.validate.. sqrTc*|Srz)rFrs rUrz$FuzzyEnum.validate.. s rTc ||vSrzrSrrs rUrz$FuzzyEnum.validate.. s 16rTc,||Srz) startswithrs rUrz$FuzzyEnum.validate.. sTUT`T`abTcTcrTc:g|]}|SrSrS)rIr conv_func match_funcrws rUrz&FuzzyEnum.validate.. s-DDDq::eYYq\\22DDDrTr)rirWrBrrrsumzip) r}rrwrrgmatchesrmrrs ` @@rUrMzFuzzyEnum.validate s%%% # JJsE " " "%)%8Q[[[>Q>Q !4.@d)))GcGc  %  +#DDDDDDGDDD w<<1  GW--  1HHH 3rTr`rWc|jr d|rdndznd}|jrdnd}|jrdnd}d |d |d |||S) rorlrmrxr sensitive insensitive substringprefixz any case- rF)rrrri)r}r`rqcasesubstrs rUrrzFuzzyEnum._info su>BoUxv9886::SU"1D{{} $ 7EXO4OO&OOd.?.?.G.GOOOOrTc.|dSrurwrs rUrAzFuzzyEnum.info rxrTc.|dSrzrwrs rUr{zFuzzyEnum.info_rst r|rT)r}rrrarrarrYrrYrrarXrxrxrrr) rPrQrRrrrrBr~rMrrrAr{rrs@rUr.r. sOON )$#( H H H H H H H"PPPPP((((''''''''rTr.c8eZdZUdZdZded<dZded<eZdZ ded<d Z ded <e j d d d d d8dZ e j d d d d d9dZ e j d d d d d dd:d#Z dedddfd;fd$ Z d<fd( Zdd.Zd?d0Zd@d3ZdAdBd7ZxZS)Cr$z\An instance of a container (list, set, etc.) To be subclassed by overriding klass. Nztype[T] | NonerYrSra _cast_types_trait)[]()_literal_from_string_pairs.rr} Container[T]rr[rrrrrr\rrXrxc dSrzrSr}rrrrrs rUr~zContainer.__init__, rrTContainer[T | None]rac dSrzrSrs rUr~zContainer.__init__8 rrT)r1rrrrr1rrWrYc dSrzrS)r}r1rrrrrs rUr~zContainer.__init__D s  rTc ||turt|s|}d}|B|dds,td|jjdt dt}|turd}nB|d}d|d <n8t||jr|f}ntd |jjd |t|rSt|trtd t d t|tr |n||_ n!|tdt|ztjd|j||||d|dS)aCreate a container trait type from a list, set, or tuple. The default value is created by doing ``List(default_value)``, which creates a copy of the ``default_value``. ``trait`` can be specified, which restricts the type of elements in the container to that TraitType. If only one arg is given and it is not a Trait, it is taken as ``default_value``: ``c = List([1, 2, 3])`` Parameters ---------- trait : TraitType [ optional ] the type for restricting the contents of the Container. If unspecified, types are not checked. default_value : SequenceType [ optional ] The default value for the Trait. Must be list/tuple/set, and will be cast to the container type. allow_none : bool [ default False ] Whether to allow the value to be None **kwargs : any further keys for extensions to the Trait (e.g. config) NrF Specifying a(default_value=None) for no default is deprecated in traitlets 5.0.5. Use default_value=Undefinedr[r\rSrdefault value of  was r{rnz'`trait` must be a Trait or None, got %s)rYrMrrr)rBrlrrr5rPr^ri_valid_defaultsrsrjrr r~r~rY) r}r1rrrrrrMr5s rUr~zContainer.__init__Q sL  )!;!;HUOO!;!ME  L%)H)H  /dn5///#     &M I % %DD  "D&*F? # #  t'; < < _!#DD]0G]]m]]^^ ^ E?? Z%&& E&  &0t%<%<G%%'''%DKK  E RWHXHXXYY Y *4diPV  Z`     rTrrwrct||jr|jJ||}t||}||S|||Srz)rirrYr~rMvalidate_elementsr}rrwr5s rUrMzContainer.validate sp eT- . . &:)))JJu%%E  e,, =L%%c5111rTcPg}|jt|jtr|S|D]a} |j||}||4#t $r!}||||Yd}~Zd}~wwxYw|jJ||Srz)rrirrrr=rBrY)r}rrw validatedrrBs rUrzContainer.validate_elements s ; *T[#">"> L $ $A $K))#q11  #### * * * 35)))))))) *z%%%zz)$$$sA B&BBrrrct|jtr|j|dt ||dSrz)rirr>rr~rs rUrzContainer.class_init sO dk9 - - . K " "3 - - - 3%%%%%rTcrt|jtr|j|dSdSrz)rirr>rrs rUrzContainer.subclass_init s< dk9 - - + K % %c * * * * * + +rTrVct|tstd| t|}n#t$rd}YnwxYw|d|S)Load value from a single stringzExpected string, got N)rirWr=rrrMr}rVrs rUr zContainer.from_string su!S!! <:Q::;; ; ??DD   DDD }}T4(((s9 AAs_listrcjJt|dkr|ddkr jrdStdkrtfdjDrwjrjjdz}nd}jJtd |jztd tStj j}d |jvrjnddfd fdt!|DS)ziReturn the value from a list of config strings This is where we parse CLI configuration Nrrrxr[c3rK|]1\}}|o|V2dSrz)rendswith)rIstartendrs rUrJz-Container.from_string_list.. sV##E3 U##7 3######rTrrz}--{0}={1} for containers is deprecated in traitlets 5.0. You can pass `--{0} item` ... multiple times to add items to a list.r\rrVrW int | NonerXT | strc.|Srzitem_from_string)rVrr}s rUrz4Container.from_string_list..item_from_string s,,Q///rTc0g|]\}}||S))rrS)rIidxrVrs rUrz.Container.from_string_list.. s. L L LQ  as + + + L L LrTrzrVrWrrrXr)rYrranyrrrPrrrOr^rr signaturer parameters enumerate)r}rrsigrrs` @@rUfrom_string_listzContainer.from_string_list s z%%% v;;!  q AF{{t{t1vv{{s####"&"A###  {?!"o6D  LuMLLVLLLLLrTrrwcld|jt||j|j|fz}t |Nz_The '%s' trait of %s instance must be of length %i <= L <= %i, but a value of %s was specified.rrrrr=rms rU length_errorzList.length_error08 my(3--t|UK L mmrTct|}||jks ||jkr|||t ||Srzrrrrr~rr}rrwlengthr5s rUrzList.validate_elements7WU DL FT\$9$9   c5 ) ) )ww((e444rTct|tr#t||gSt||SrzrirWr~r+rs rUr+zList.set>G eS ! ! +77;;sUG,, ,77;;sE** *rT) r1rrrrrrrrrarXrxrrarwrarXrxr)rPrQrRrrrYrrrrBsysmaxsizer~rrr+rrs@rUr4r4s'' EK!!!!\`MVk $M$M$M$M$M$M$ML555555++++++++++rTr4cpeZdZdZeZeefZdZ de de j fdfd Z ddZdfd Zdfd ZddZxZS)r:zAn instance of a Python set.)rrz{}Nrr1rarrrrrrXrxc \||_||_tjd||d|dS)aCreate a Set trait type from a list, set, or tuple. The default value is created by doing ``set(default_value)``, which creates a copy of the ``default_value``. ``trait`` can be specified, which restricts the type of elements in the container to that TraitType. If only one arg is given and it is not a Trait, it is taken as ``default_value``: ``c = Set({1, 2, 3})`` Parameters ---------- trait : TraitType [ optional ] the type for restricting the contents of the Container. If unspecified, types are not checked. default_value : SequenceType [ optional ] The default value for the Trait. Must be list/tuple/set, and will be cast to the container type. minlen : Int [ default 0 ] The minimum length of the input list maxlen : Int [ default sys.maxsize ] The maximum length of the input list rNrSrrs rUr~z Set.__init__NrrTrrwcld|jt||j|j|fz}t |rrrms rUrzSet.length_errortrrTct|}||jks ||jkr|||t ||Srzrrs rUrzSet.validate_elements{rrTct|tr#t||hSt||Srzrrs rUr+zSet.setrrTrWctt|pg}|dkrdSd|ddzdzS)Nrzset(){rre})r^rr )r} list_reprs rUr_zSet.default_value_reprsP 9 9 ; ; ArBBCC   7Yqt_$s**rT) r1rarrarrrrrrarXrxrrr)rPrQrRrr+rYrrrrrBrrr~rrr_rrs@rUr:r:Es&& E$-K!3 (k $M$M$M$M$M$M$ML555555++++++ ++++++++rTr:cReZdZdZeZefZdfd Zdd Z ddZ dfd Z ddZ xZ S)r?zAn instance of a Python tuple.rrarrXrxc|dt}t|dkr(|turt|ds |d}d}|B|dds,t d|jjd td t}|turd}nB|d}d|d<n8t||j r|f}ntd |jjd |g|_ |D]R}t|tr!t dtd |}|j |S|j r | |turd}tt |jd|j|d|dS)aGCreate a tuple from a list, set, or tuple. Create a fixed-type tuple with Traits: ``t = Tuple(Int(), Str(), CStr())`` would be length 3, with Int,Str,CStr for each element. If only one arg is given and it is not a Trait, it is taken as default_value: ``t = Tuple((1, 2, 3))`` Otherwise, ``default_value`` *must* be specified by keyword. Parameters ---------- *traits : TraitTypes [ optional ] the types for restricting the contents of the Tuple. If unspecified, types are not checked. If specified, then each positional argument corresponds to an element of the tuple. Tuples defined with traits are of fixed length. default_value : SequenceType [ optional ] The default value for the Tuple. Must be list/tuple/set, and will be cast to a tuple. If ``traits`` are specified, ``default_value`` must conform to the shape and type they specify. **kwargs Other kwargs passed to `Container` rrrrSNrFrrr[r\rr~Traits should be given as instances, not types (for example, `Int()`, not `Int`) Passing types is deprecated in traitlets 4.1.rYrM)rrBrrlrrr5rPr^rirrsrrjrr~r$r~rY)r}rrrrMr1r5s rUr~zTuple.__init__s< ?I>> v;;!    : :8FSTICVCV :"1IMF  L%)H)H  /dn5///#     &M I % %DD  "D&*F? # #  t'; < < _!#DD]0G]]m]]^^ ^  ' 'E%&& E&   L   & & & & < ]2my6P6PD'i'NdjtNNvNNNNNrTrVrWrrc|jr|t|jkr|S|j||Sr)rrr rs rUrzTuple.item_from_stringsD | uDL(9(999H|E"..q111rTrrwc|js|St|t|jkrId|jt|t|jt |fz}t |g}t |j|D]_\}} |||}||2#t $r!}| |||Yd}~Xd}~wwxYwt|S)NzTThe '%s' trait of %s instance requires %i elements, but a value of %s was specified.) rrrrr r=rrrrBr)r}rrwrrr1rrBs rUrzTuple.validate_elementss| L u::T\** * *f9hsmmS->-> %@P@PQR Q--  DL%00 $ $HE1 $OOC++  #### * * * 35)))))))) *YsC C, C''C,rrrrc|jD]-}t|tr||d.t t |||dSrz)rrir>rr~r$r}rrr1r5s rUrzTuple.class_initsc\ , ,E%++ ,  d+++ i))#t44444rTcn|jD],}t|tr||-dSrz)rrir>rr}rr1s rUrzTuple.subclass_init sD\ ) )E%++ )##C((( ) )rT)rrarrarXrx)rVrWrrrXrarrr)rPrQrRrrrYrrr~rrrrrrs@rUr?r?s(( E'KKOKOKOKOKOKOZ 2 2 2 2    *555555 ))))))))rTr?ceZdZdZdZdZdddefd(fd Z d)d*dZd+fd Z d,dZ d-fd Z d.d Z d/d"Z d0d%Zd1d'ZxZS)2r&aAn instance of a Python dict. One or more traits can be passed to the constructor to validate the keys and/or values of the dict. If you need more detailed validation, you may use a custom validator method. .. versionchanged:: 5.0 Added key_trait for validating dict keys. .. versionchanged:: 5.0 Deprecated ambiguous ``trait``, ``traits`` args in favor of ``value_trait``, ``per_key_traits``. N value_trait6TraitType[t.Any, t.Any] | dict[K, V] | Sentinel | Noneper_key_traitsra key_traitTraitType[t.Any, t.Any] | Nonerdict[K, V] | Sentinel | NonerrXrxc X|dd}|*|td|}tdtd|dd}|*|td|}td td|tur,|*t |st |trJ|}d}||t |r|}d}|turi}|d}nDt |tr|f}n+t |tr|f}ntd |zt |r>t |tr!td td|}||_ n!|td t|zt |r>t |tr!td td|}||_ n!|td t|z||_tjdt|d|dS)aCreate a dict trait type from a Python dict. The default value is created by doing ``dict(default_value)``, which creates a copy of the ``default_value``. Parameters ---------- value_trait : TraitType [ optional ] The specified trait type to check and use to restrict the values of the dict. If unspecified, values are not checked. per_key_traits : Dictionary of {keys:trait types} [ optional, keyword-only ] A Python dictionary containing the types that are valid for restricting the values of the dict on a per-key basis. Each value in this dict should be a Trait for validating key_trait : TraitType [ optional, keyword-only ] The type for restricting the keys of the dict. If unspecified, the types of the keys are not checked. default_value : SequenceType [ optional, keyword-only ] The default value for the Dict. Must be dict, tuple, or None, and will be cast to a dict if not None. If any key or value traits are specified, the `default_value` must conform to the constraints. Examples -------- a dict whose values must be text >>> d = Dict(Unicode()) d2['n'] must be an integer d2['s'] must be text >>> d2 = Dict(per_key_traits={"n": Integer(), "s": Unicode()}) d3's keys must be text d3's values must be integers >>> d3 = Dict(value_trait=Integer(), key_trait=Unicode()) r1NzFFound a value for both `value_trait` and its deprecated alias `trait`.zIKeyword `trait` is deprecated in traitlets 5.0, use `value_trait` insteadr[r\rzJFound a value for both `per_key_traits` and its deprecated alias `traits`.zMKeyword `traits` is deprecated in traitlets 5.0, use `per_key_traits` insteadzdefault value of Dict was %srz-`value_trait` must be a Trait or None, got %sz+`key_trait` must be a Trait or None, got %srrS)rrsrr^rBrlrir>rrrj _value_traitr _key_trait_per_key_traitsr~r~) r}rrrrrr1rrMr5s rUr~z Dict.__init__#s\ 7D))  &\ K ["     Hd++  )`$N _"     I % %+*AK(( #%k9===== + "  !;'' &* !% I % %M  DD  t , , L!#DD  } 5 5 L!#DD:]JKK K K +t,, ,E&  *kmm +D    $?)KBXBXX  I   b)T** (E&  &IKK 'DOO  "IIV_L`L``aa a-9t$99&99999rTValuesrelement validatorsiderWc |d|jdt|d|dt|d z}t |)Nz of the 'rkz instance must be rz was specified.)rrrAr r=)r}rrrrrs rU element_errorzDict.element_errors X$)XX XXQZQ_Q_QaQaXXt}FuGuGXXX X mmrTrwdict[K, V] | Nonec|t||}||S|||Srz)r~rMrrs rUrMz Dict.validates<  e,, =L%%c5111rTdict[t.Any, t.Any]c|jpi}|j}|j}|s|s|s|Si}|D]}||}|r@ |||}n(#t$r||||dYnwxYw|||} | r@ | ||}n(#t$r|||| dYnwxYw|||<||S)NKeysr)rrrrr=rrrY) r}rrwper_key_overriderrrrractive_value_traits rUrzDict.validate_elementssV/52O '  [ ,< L   Cc A DD#--c377CC!DDD&&sCFCCCCCD!1!5!5c;!G!G ! MM*44S!<rrrrr~r s rUrzDict.class_inits d' 3 3 4   ( (d 3 3 3 doy 1 1 2 O & &sD 1 1 1   +-4466 , ,  d++++ 3%%%%%rTcJt|jtr|j|t|jtr|j||j1|jD]}||dSdSrz)rirr>rrrrr s rUrzDict.subclass_inits d' 3 3 1   + +C 0 0 0 doy 1 1 / O ) )# . . .   +-4466 ) )##C(((( , + ) )rTrVc t|ts"td|dt| ||gS#t $r*t |}t|tr|cYSwxYw)rz"from_string expects a string, got z of type )rirWrsrjrrrfrrs rUr zDict.from_strings!S!! ZXXXtTUwwXXYY Y ((!-- -   %a((D$%%    sA0BBrrc t|dkr|ddkr jrdSt|dkr||ddra|ddrFt djd|dd jd t d t|dSi}fd |DD]}|||S)zReturn a dict from a list of config strings. This is where we parse CLI configuration. Each item should have the form ``"key=value"``. item parsing is done in :meth:`.item_from_string`. rrrxNrrz--rz@ for dict-traits is deprecated in traitlets 5.0. You can pass --z7 ... multiple times to add items to a dict.r[r\c:g|]}|SrSr)rIrVr}s rUrz)Dict.from_string_list..s';;;q$''**;;;rT) rrrrrrr^rr)r}rcombinedrs` rUrzDict.from_string_lists" v;;!  q V 3 3 34 v;;!  q 4 4S 9 9 fQi>P>PQT>U>U  eTYeeee"&)eee"      q ** *;;;;F;;;  A OOA    rT dict[K, V]c6d|vrtd|jjd||dd\}}|jr|j|}|jpi||j}|r||}||iS)aCast a single-key dict from a string. Evaluated when parsing CLI configuration from a string. Dicts expect strings of the form key=value. Returns a one-key dictionary, which will be merged in :meth:`.from_string_list`. rr=z.' options must have the form 'key=value', got r) r=r5rPrrr rrr)r}rVrrwrs rUrzDict.item_from_strings a<<`DN+``[\`` WWS!__ U ? 3/--c22C+1r66sD/4%)#      rTr;ceZdZdZdZd dZd S) rzA casting compiled regular expression trait. Accepts both strings and compiled regular expressions. The resulting attribute will be a compiled regular expression.za regular expressionrrarwrXre.Pattern[t.Any] | Nonecz tj|S#t$r|||YdSwxYwrz)recompilerrBrs rUrMzCRegExp.validatelsO #:e$$ $ # # # JJsE " " " " " " #s  ::N)rrarwrarXr=rPrQrRrrrMrSrTrUrrds988 'I######rTrzre.Pattern[t.Any]ceZdZUdZdZded<dZ ddfd ZefddZ efddZ d dZ d!d"dZ d!d"dZ d#dZd#dZxZS)$rDasUse a Enum class as model for the data type description. Note that if no default-value is provided, the first enum-value is used as default-value. .. sourcecode:: python # -- SINCE: Python 3.4 (or install backport: pip install enum34) import enum from traitlets import HasTraits, UseEnum class Color(enum.Enum): red = 1 # -- IMPLICIT: default_value blue = 2 green = 3 class MyEntity(HasTraits): color = UseEnum(Color, default_value=Color.blue) entity = MyEntity(color=Color.red) entity.color = Color.green # USE: Enum-value (preferred) entity.color = "green" # USE: name (as string) entity.color = "Color.green" # USE: scoped-name (as string) entity.color = 3 # USE: number (as int) assert entity.color is Color.green Nzenum.Enum | Nonerz"Trait type adapter to a Enum class enum_classrrarrXrxc Rt|tjs Jd|z|dd}|5|s3t t |j}tj dd|i|||_ |j dz|_ dS)NzREQUIRE: enum.Enum, but was: %rrFrrrS) rkenumr(rnextiter __members__rr~r~rCrP name_prefix)r}rCrrrr5s rUr~zUseEnum.__init__s*di00``2SV`2```0ZZ e44    j&<&C&C&E&E!F!FGGM??}????$%.4rTrwrrFct|tsJ|jj}|D]}|j|kr|cS|S)z0Selects enum-value by using its number-constant.)rirrCrHrrw)r}rwrF enum_members enum_items rUselect_by_numberzUseEnum.select_by_numbersb%%%%%%2 %,,.. ! !I%''    (rTrWct|tsJ||jr||jdd}|jj||S)z4Selects enum-value by using its name or scoped-name.rr)rirWrrIreplacerCrHr)r}rwrFs rUselect_by_namezUseEnum.select_by_namesd%%%%%%   D, - - ;MM$"2B::E*..ug>>>rTrc\t||jr|St|tr!||}|tur|SnHt|t r!||}|tur|Sn||jrdS|jS| ||dSrz) rirCrrMrBrWrPrrrB)r}rrwvalue2s rUrMzUseEnum.validates eT_ - - *L s # # ***511FY&& ' s # # *((//FY&& ' ] *t)) 3rTFr`rYc|jj}|rdd|DSt t |S)rbrcc3 K|] }d|zV dSrerSrfs rUrJz'UseEnum._choices_str..s&::QHqL::::::rT)rCrHrXrNr^r)r}r`rgs rUrizUseEnum._choices_strsU/-2244  '88::'::::: :W && &rTcZ|jr d|rdndznd}d|||Srkrorps rUrrz UseEnum._inforsrTc.|dSrurwrs rUrAz UseEnum.inforxrTc.|dSrzrwrs rUr{zUseEnum.info_rstr|rTrz)rCrrrarrarXrx)rwrrFrarXra)rwrWrFrarXrarrrr)rPrQrRrrrrr~rBrMrPrMrirrrAr{rrs@rUrDrDss:'+M****4I?C 5 5 5 5 5 5 5=F;D?????(''''';;;;; ((((''''''''rTrDceZdZdZdZd dZdS) r zxA trait which is callable. Notes ----- Classes are callable, as are instances with a __call__() method.z a callablerrarwrXcTt|r|S|||dSrz)r&rBrs rUrMzCallable.validates/ E?? #L JJsE " " " " "rTNrrArSrTrUr r s9!!I######rTr )rVrWrXrYr)rgrarXrY)rmrnrXrorz)rrarrarXr)rrarXrx)rcrarXrb)rmrrjrWrXr9)rrrXr)rmrrXrE)rrWrXr%)r1rrrarwrarXra)r __future__rrrErrr"r?rrgtypingrgastr utils.bunchrutils.descriptionsrrr r utils.getargspecr utils.importstringr utils.sentinelrutils.warningsrrrrrr+ frozensetrrj ClassTypesrytyping_extensionsr__all__rBrNoDefaultSpecifiedrr=r_rfrlrLrvrrrIrGrHrrrrrrrWrrrGenericr>rbrrr6r7rJrKrMrFr rr)r9rEr%r/r0r"r@r1r,r-r+Optionalr<rCrr2rr5rr3r*rrrrr#rrrrrArr8r'rrr(r!r.r$r4r:r?r&r;rrDrSrTrUrjsN!!R#"""""  JJJJJJJJJJJJ((((((++++++$$$$$$@@@@@@@@@@uc9- W ?)))))))< < < J H   h             ZZZZ 6        ( D D D DTLTLTLTLTLTLTLTLn@E@E@E@E@E@E@E@EF 7 7 7 7 7 7 7 7 t GCLL GCLL GCLL ? ////////S!!!AQU###AA  A A A(A(A(A(A( !Q$A(A(A(R !G!G!G!G!G!G!G!GH$$$$6+6+6+6+6+6+6+6+rVLVLVLVLVL&VLVLVLr19,,,,,,<####L""""B& & & & R  'CJ!788811111>1114=====\===99999l999>>>>>\>>>1   ,#####w '15.1###     IeUl #   B#####UIeQUl+###I I I I I i1oI I I X,#,#,#,#,#wq!t}iQU 3,#,#,#^38$,zHHHHH9QT?HHHV,#,#,#,#,#DAJ,#,#,#^V3V3V3V3V39QT?V3V3V3r'''''d1g'''B/'/'/'/'/'Q/'/'/'daaaaa aaaH>+>+>+>+>+9QVAY >+>+>+BH+H+H+H+H+)AE!%L !H+H+H+V|)|)|)|)|)IagaeSj) *|)|)|)BNNNNN8L !NNNb?????1a4???D # # # # #i+QW5H#5M-NNO # # #c'c'c'c'c'iqu %c'c'c'L#####yCJ/CJ1GGH#####rT