K i)Q  dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddlmZddlmZmZmZmZddlmZdd lmZdd lmZdd lmZmZmZee e!e"fZ#e$fZ%e jLrdd l'm(Z(ndd l m(Z(gd Z)edddZ*edddZ+e*Z,Gdde-Z.ddZ/ddZ0ddZ1ddZ2GddZ3dddZ4ddZ5GddZ6Gdd Z7e7Z8Gd!d"Z9e(d#Z:e(d$Z;e(d%ZZ>e(d'e?(Z@e(d)e j(ZBGd*d+e9e je:e;fZDGd,d-ZEdd.ZFGd/d0e$ZGGd1d2eGZHd3d4dd6ZIdd8ZJdd:ZKdd<ZLe jPd7e jd=e jf>ZNGd?d@e9ZOGdAd5eOZPGdBd9eOZQGdCd;eOZRGdDdEeGFZSGdGdHeSeHFZTGdIdJeDe:e;fZUGdKdLeUe:e;fZVGdMdNeUetype issubclass)rXs rUis_traitrgs' a # Y 1d(;(X 1i@XYrTc |tust|tr|gSt|tr t d|rt|vrtgS|D]7}t|trt dt |j d|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 ())rrdstrr TypeErrorrerP)namesns rUrLrLs |z%-w E8 $QRRu 5L YAa%"=d1g>N>N=OqQRPUUV WXX Y rTc,eZdZddZddZddZddZy) _SimpleTestc||_yrWvalueselfrss rU__init__z_SimpleTest.__init__s  rTc2t||jk(SrW)rZrs)rutests rU__call__z_SimpleTest.__call__sDDJJ&''rTc d|jzS)NzBC C DrTcdeZdZdZdZd d dZd dZejd dZ ddZ ddZ d d Z y)rIaRLink traits from different objects together so they remain in sync. Parameters ---------- source : (object / attribute name) pair target : (object / attribute name) pair transform: iterable with two callables (optional) Data transformation between source and target and target and source. Examples -------- >>> 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 FNct||||c|_|_|r|ndfdz\|_|_|j y)Nc|SrWrSxs rUzlink.__init__..+sVWrTr)rsourcetarget _transform_transform_invrIrurr transforms rUrvz link.__init__(s@vv&#)6  T[\]K],, rTc | t|jd|jd|jt|jd|jd|jdj |j |jd|jdj |j|jdy#|jdj |j |jd|jdj |j|jdwxYwNrrrm)setattrrrrrrJ_update_target_update_sourcer{s rUrIz link.link/s N  A A A A GH  KKN " "4#6#6dkk!n " M KKN " "4#6#6dkk!n " M KKN " "4#6#6dkk!n " M KKN " "4#6#6dkk!n " Ms AC A0D;c#JKd|_ dd|_y#d|_wxYwwNTFupdatingr{s rU_busy_updatingzlink._busy_updating;#  " !DMEDM## #cn|jry|j5t|jd|jd|j |j t |jd|jd|j k7rtd|d dddy#1swYyxYw)Nrr Broken link z5: the source value changed while updating the target.) rrrrrnewrrr=ruchanges rUrzlink._update_targetCs ==   "  DKKNDKKNDOOFJJ4O Pt{{1~t{{1~6&**D "4&(aaE    BB++B4cn|jry|j5t|jd|jd|j |j t |jd|jd|j k7rtd|d dddy#1swYyxYw)Nrrrz5: the target value changed while updating the source.) rrrrrrrrr=rs rUrzlink._update_sourceMs ==   "  DKKNDKKND4G4G 4S Tt{{1~t{{1~6&**D "4&(aaE   rc|jdj|j|jd|jdj|j|jdyr)r unobserverrrr{s rUunlinkz link.unlinkWsT A  !4!4DKKN K A  !4!4DKKN KrTrWrrrrrrrrrrrrrrrr) rPrQrR__doc__rrvrI contextlibcontextmanagerrrrrrSrTrUrIrI sC0H N""LrTrIc\eZdZdZdZd d dZd dZejd dZ d dZ d dZ y)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 FNcr|r|nd|_t||||c|_|_|j y)Nc|SrWrSrs rUrz+directional_link.__init__..~srT)rrrrrIrs rUrvzdirectional_link.__init__}s0'0)kvv&#)6  T[ rTc  t|jd|jd|jt|jd|jd|jdj |j |jdy#|jdj |j |jdwxYwr)rrrrrrJ_updater{s rUrIzdirectional_link.links G  A A A A GH  KKN " "4<z!A base class for all trait types.dict[str, t.Any]metadataFrZ allow_none read_only any valuerk info_textr default_valueNc ||tur||_|r||_|||_||nd|_|jr|j|_t |dkDr"d}tj}|J|jjdk(r/|dz }|j}|J|jjdk(r/|jjdxsd} | jddd} d| gt|} t!| rt#d |d t$| t |j&dkDr;|j&j)|_|j&j+|n'||_n|j&j)|_|||j&d <|||j&d <yy)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. NrrrvrP.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') stacklevelconfighelp)rBrrrrrrinspect currentframef_codeco_namef_back f_globalsgetsplitsortedrrDeprecationWarningrcopyupdate) rurrrrrkwargsrfmodpkgrs rUrvzTraitType.__init__s,  )!.D  (DO  &DN ,D" 9999DL v;?J$$&A= =((""j0a HH}$}((""j0++//*-3C))C#A&C!388C3x(DD') 4==!A% $ 2 2 4  $$V, &  MM..0DM  &,DMM( #  $(DMM& ! rTc*|jr|dk(ry|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 rNrrur]s rU from_stringzTraitType.from_string?s ??qF{rTc|jtur$tjt|jSt |dr(tjt|j Stjt|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)rrBrXrYrhasattrrrs rUrFzTraitType.defaultOsg   Y .66!T//0 0 T1 266!T6689 966!T//0 0rTcntdtdtjt|j S)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 attributerr)rrrXrYrrr{s rUget_default_valuezTraitType.get_default_value_s. `  vva++,,rTctdtd|j||j}||j|j <|S)z  +**I +  F s#BB!BB! B/.B/cp|jrtd|jz|j||y)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. >>;diiGH H erTc||jr|St|dr|j||}|jdur|j ||}t j t|S)NrMF)rr rMr_cross_validaterXrYrrs rUr zTraitType._validates] =T__L 4 $MM#u-E  % % .((e4EvvarTcp|j|jvr0t|||d}|j|j||}nUt|d|jzrz"TraitType.error..s#MHS!$4#MsrzDThe '{}' 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=r9r)rurrserrorr9chainrs rUrEzTraitType.errors@   JJ4' !Jyy$ #Mejjn#MM?//5v II$T3/!!JJqM$UEJJqM: 0 "EJ&KSYY II!!JJqM$UEJJqM: "EJK 99 UD$7DIIK> > ?DKK  # & Am 6<< # &A mrTcx|dk(rd}nd}td|ztd|jj||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, rr)rrrr)rurrFmsgs rU get_metadatazTraitType.get_metadataAs@ &=GCxC ,s 24FSTU}}  g..rTc`|dk(rd}nd}td|ztd||j|<y)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] = valuerHrrN)rrr)rurrsrIs rU set_metadatazTraitType.set_metadataMs7 &=OC`C ,s 24FSTU" crTc t|jjhd}|rtd|ztd|j 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 rr)r$keys intersectionr UserWarningrr)rurmaybe_constructor_keywordss rUtagz TraitType.tagYsZ&)%9%F%F @& " & u,-   X& rTc,t|jSrW)reprrr{s rUdefault_value_reprzTraitType.default_value_reprrsD&&''rT)ruzTraitType[G, S]rrrrZr bool | Nonerrrrrrrr)r]rkrG | NonerW)rrrrW)rrW)rr0rztype[t.Any] | NonerrW)rrr type[t.Any]rr)rrrrXrr)rHasTraits | NonerrXrzSelf | G)rr0rsrrr)rrrsrrrW)r6zTraitType[t.Any, t.Any]rrCr)NN) rrYrsrrEzException | Noner9rrz t.NoReturn)rrkrFrrr)rrkrsrrr)rrrr)rPrQrRrrrrrrrBrrvrrFr rrrXoverloadrr$r&r r(r7r9rErJrLrRrUrSrTrUr>r>si+!#H#JIt Is $M5$ ) !% B)B)B)B) B)  B)  B)B) B)H 1 - %$NZZ  ZZ   1?&  ( #' O OO O  O  Ob / #2(rTr>c(eZdZdZddZddZddZy) _CallbackWrapperzAn object adapting a on_trait_change callback into an observe callback. The comparison operator __eq__ is implemented to enable removal of wrapped callbacks. c||_t|jtjrdnd}t t |d|z|_|j dkDr tdy)Nrz1a trait changed callback must have 0-4 arguments.)cbrdtypes MethodTyperr nargsr=)rur`offsets rUrvz_CallbackWrapper.__init__sY!$''5+;+;<!B*+f4 ::>PQ Q rTct|tr"t|j|jk(St|j|k(SrW)rdr\rZr`r5s rU__eq__z_CallbackWrapper.__eq__s9 e- .588+, ,5() )rTc |jdk(r|jy|jdk(r|j|jy|jdk(r'|j|j|jy|jdk(r2|j|j|j|jy|jdk(r=|j|j|j|j|j yy)Nrrrr_)rcr`rroldrrs rUryz_CallbackWrapper.__call__s ::? GGI ZZ1_ GGFKK ZZ1_ GGFKK , ZZ1_ GGFKKVZZ 8 ZZ1_ GGFKKVZZ FrTN)r`rrr)r6rrrZrrrr)rPrQrRrrvrfryrSrTrUr\r\{s R* GrTr\c<t|tr|St|SrW)rdr\)r`s rU_callback_wrapperrls"&' ##rTcdeZdZdZ dfd Z dfd ZddZxZS)r6zA metaclass for HasDescriptors. This metaclass makes sure that any TraitType class attributes are instantiated and sets their name attribute. c |jD]H\}}tj|st|ts-t dt d|||<Jt| ||||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.rr) itemsrisclassrfr>rrsuper__new__)mclsrbases classdictkwdskvr.s rUrszMetaHasDescriptors.__new__ssOO% #DAqq!jI&>E&  !s !  #wtT5)DtDDrTc Lt||||fi||j|y)z-Finish initializing the HasDescriptors class.N)rrrv setup_class)rrrurvrwr.s rUrvzMetaHasDescriptors.__init__s' ui848  "rTc6g|_g|_|jD](\}}t|ts|j ||*t |D]B\}}t|ts|j||jj|Dy)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) _descriptorsrrprdrrrrr)rrvrxry_s rUr{zMetaHasDescriptors.setup_classs+-OO% %DAq!^, S!$ %sO +DAq!^,$  ''* +rT) rtztype[MetaHasDescriptors]rrkrutuple[type, ...]rvrrwrrr6) rrkrurrvrrwrrr)rr6rvrrr)rPrQrRrrsrvr{ __classcell__r.s@rUr6r6s~ E&EE E$ E  E  E0##/#t@fvr6t|j"tBs| r|j"|j|<nt'|tDk(rFt|j"tBt0t6t<fs| r|j"|j|<nqt'|tFk(r|j"d|j|<nCt|tHr3|jJ'|jL|j$rd|j|<|jN|j|<2y#t$rY@wxYw#t$rYwxYw)N _%s_defaultr_trait_default_generators)(r_all_trait_default_generators_traits _static_immutable_initial_valuesrrr{mrorrrrdr>indexrra__dict__rrrrerr2minmaxintrr*floatrrrZrrArkrrCr1 default_argsdefault_kwargsrF) rrvrrrsr*default_method_name mro_traitcnone_okr.s rUr{zMetaHasTraits.setup_classs/:<%,.) /1, I&ggiHG LD T*%+$) D!&3d&:#  #$Ecii0@0@&AA&E FI#5LA*ajj8BC**M`Ba99$?qzz~~.I2NNBCB]B]^bBc99$? 5L$11T9Ne>N>NGU c{2!II-!II-'(;(;SAWEJEXEX<.compatible_observerdst nd +>*Fnn--G wir.)99z{"  # FD&!!rT) rurrrkrirrrrr)rBrXrYr)rrs` rUrKrKVsL8Ay""%("/4"GL" "* 66%, --rTrEc|s td|D])}|tus t|trtd|zt |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)rlrrdrkrE)rmrs rUrMrM|sS2 MNN] s?:dC#8TW[[\ \] 5 !!rTr%cTt|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)rdrkrlr%)rs rUrFrFs+H dC DtKLL $ rT.)boundcreZdZddZej ddZej d dZd dZd d dZy) r)c||_|SrW)r)rurs rU _init_callzEventHandler._init_calls  rTcyrWrS)rurrBrs rUryzEventHandler.__call__rrTcyrWrSrurBrs rUryzEventHandler.__call__rrTcbt|dr|j|i|S|j|i|S)zCPass `*args` and `**kwargs` to the handler's function if it exists.r)r rrrs rUryzEventHandler.__call__s8 4 499d-f- -"4??D3F3 3rTNcJ||Stj|j|SrW)rarbr)ruinstrs rUrzEventHandler.__get__s# <K 400rT)rrrr))rrrBrrrrrrBrrrrrrW)rrrrrztypes.MethodType | EventHandler)rPrQrRrrXrZryrrSrTrUr)r)sAZZ  ZZ  41rTr)ceZdZdddZddZy)r9c ||_||_yrW) trait_namesre)rurmres rUrvzObserveHandler.__init__s  rTcT|j||j|jy)Nr)rJrrerurs rUrzObserveHandler.instance_inits T4++$)) >rTc,eZdZdZdfd ZddZxZS)r/z5The base class for all classes that have descriptors.c|d}|dd}tt| }|tjur ||}n ||g|i|}|j|i||Sr)rrr/rsrsetup_instance)rBrrnew_methrr.s rUrszHasDescriptors.__new__sh1gABx5 v~~ %C=DC1$1&1DT,V, rTcp|d}|dd}d|_|j}|jD] }|| y)zD This is called **before** self.__init__ is called. rrNF)rr.r)rBrrurinits rUrzHasDescriptors.setup_instancesG AwABx&+#nn '' D J rTrrBrrrrr)rPrQrRrrsrrrs@rUr/r/s? rTr/) metaclasscZeZdZUded<ded<ded<ded<ded<ded <ded <d+fd Zd+fd Zd,d Zd-dZee jd.dZ e jd.dZ d/dZ d0dZd1dZ d2dZ d3dZ d4 d5dZedf d6dZedf d6dZefd7dZ d8dZd9dZd:dZed;dZedd#Z d?d$Z!d@d%Z"dAd&Z#dBd'Z$dCdDd(Z%edEfd) Z&edCdFd*Z'xZ(S)Gr0rrrzdict[str | Sentinel, t.Any]_trait_notifiersr-rZrrrc|d}|dd}|jj|_i|_i|_d|_t t|"|i|y)NrrF) rrrrr-rrrr0r)rBrrur.s rUrzHasTraits.setup_instance+s\AwABx "BBGGI "!#&+# i-t>v>rTcl|}i}|rd d}||_d|_i}|jD]<\}}|j|r!t |||t |d||d||<8|||<>t |t |jz} | D]E}|j|j|t||}|j|||||d<Gd|_|`| D]}|j|| t|0|i|y#t$r} |D cgc] } t| ncc} w} } |jD]\} }| j| d|dj!| }t#d j%||j&j(| t*d Yd} ~ yd} ~ wwxYw)NrcyrWrS)rs rUignorez"HasTraits.__init__..ignoreCsrTTrrirrrerF=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 classnamerErrrj) notify_changerrp has_traitrrr$rr(r set_traitrrrvrlrTrrCrrDr.rPr)rurBr super_args super_kwargsrchangesrrschangedrarg arg_s_listrxryrr.s rUrvzHasTraits.__init__9s   "(D *.D 'G$lln . U>>#&D#u-#(  !"% $GCL).L% .&kC $55G , S)99$c@RSsE*&+ U# ,+0D '" 1""73<0 1  G j 9L 9 /9:$s)::J:$**, 01!!QCq,/ 0IIj)E NOUf"nn55OUO #    s%;D F3F.D+*A?F..F3c|jj}i|d<i|d<|jj|d<d|d<|S)Nrr-rFr)rrr)ruds rU __getstate__zHasTraits.__getstate__vsU MM   !# !# !//446/&+ "#rTc|j|_|j}t|D]1} t ||}t |t s!|j|3y#t$rY@wxYwrW) rrr.rrrdr)rr)rustaterrrss rU __setstate__zHasTraits.__setstate__sl  nns8 .C .S)e\2''- . "  s A"" A.-A.c#lK|jrdy d|_dd|_y#d|_wxYww)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)rr{s rUcross_validation_lockzHasTraits.cross_validation_locks7  & &   4.2+.3+e+s4 (4 14c#R K|jrdyid d d  fd } ||_d|_dtjD]F}t |j |}|j |t ||}|j||H d|_|`jD]}|D]}|j|y#t$r}d|_jD]l\}}|dddD]\}|jdk(s|jtur|j||jB|jj|^ni|d}~wwxYw#d|_|`jD]}|D]}|j|wxYww) 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. Nrc||gS|dddk(r#|jdk(r|j|dd<|S|j||S)z5Merges the provided change with the last if possible.r^rerr)rerr) past_changesrs rUcompressz4HasTraits.hold_trait_notifications..compresss]'"8O#B'/8; x@W28** R(/('%++F3''rTcT|j}j|||<yrW)rr)rrcachers rUholdz0HasTraits.hold_trait_notifications..holds${{&uyy?d rTTcyrWrSrs rUrz4HasTraits.hold_trait_notifications..rrTr^F)rzlist[Bunch] | Nonerrrz list[Bunch]rj)rrlistrNrr.r(rr=rprerirBrpopvalues) rurrr*rsrrrrrs @@rUhold_trait_notificationsz"HasTraits.hold_trait_notificationss  & &  ,.E ( @ 3&*".2+ .0D#DNND9E!11$d8KLENN4/0$/4+& %||~3G")3**6233' %3"%*[[]=MD'")$B$-=!;;(2%zz: $tVZZ @ $ 2 2 6 6t < == /4+& %||~3G")3**6233s<F'A4C7F' E)8E$AE$$E))E,,8F$$F'c B|jt||||dy)Nrr)rr)rurr"r!s rUr zHasTraits._notify_traits'     rTrc$|j|S)z"Notify observers of a change event)rrs rUrzHasTraits.notify_changes%%f--rTcHt|ts t|}|d|d}}g}||jvrz|j|jj |ij |g|j|jj |ij t gt |jvr|j|jj t ij |g|j|jj t ij t gd|z}|ddk(rtt ||rht|j|}t|tsBt||j|dt||}||vr|jt||D]Y}t|tr |j}n2t|tr"|j t||j }||[y)zNotify observers of any eventrrez _%s_changedrz$use @observe and @unobserve instead.N)rdrrextendrrr rr.r9rrrlr\ryr)r) rueventrre callables magic_name class_valuer`rs rUrzHasTraits._notify_observerss%'%LE6]E&Md 4(( (   T2266tR@DDT2N O   T2266tR@DDS"M N $'' '   T2266sB?CCD"M N   T2266sB?CCCL M#T) =H $z)B!$..*=Kk>:!NN:  T:.Y&$$%6r%:; A!-.JJA|,1CD!&&) eH rTc||jvrg}||i|j|<n8||j|vrg}||j||<n|j||}||vr|j|yyrW)rr)ruhandlerrrenlists rU_add_notifierszHasTraits._add_notifiers"s t,, ,!#E+/-D ! !$ '4006649%%d+D1--d3D9 %  LL ! rTc ||j||=y|j||j|y#t$rYywxYwrW)rremover)rurrres rU_remove_notifierszHasTraits._remove_notifiers1sO ))$/5%%d+D188A   s7!7 AActdtd|t}|r|jt ||y|j t ||y)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 insteadrrNr)rrrrrlrJ)rurrrs rUon_trait_changezHasTraits.on_trait_change<sQB Q  <D  NN,W5TN B LL*734L @rTcJt|D]}|j|||y)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)rLrrurrmrers rUrJzHasTraits.observeis*>(. 5D   t 4 5rTcJt|D]}|j|||y)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)rLrrs rUrzHasTraits.unobserves*,(. 8D  " "7D$ 7 8rTc^|turi|_y |j|=y#t$rYywxYw)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_alls8 3;$&D ! ))$/  s ,,c|D]S}d|z}t||st|j|}t|trForcibly sets trait attribute, including read-only attributes.Class  does not have a trait named N)r.rr=rPrr$)rurrsrs rUrzHasTraits.set_traitsMnn~~d#vcll^3PQUPVWX XTtU+rTc 8t|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$$0x011rTc <|jj}t|dk(r|Si}|jD]\\}}|jD]?\}}t |s t |}||j j|dr?W|||<^|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. rNrrrrpcallablerprr)rrrresultrr* meta_name meta_evals rUr zHasTraits.class_traitss"!!# x=A M!<<> %KD%(0(8 %$ 9 * +I 6I !3!3It!DE  % %t  % rTc t||}|jdi|jDcic]\}}t||d|ur||c}}Scc}}w)zGet a dict of all the traitlets defined on this class, not a parent. Works like `class_traits`, except for excluding traits from parents. NrS)rrr rpr)rrsuprnrXr.s rUclass_own_traitszHasTraits.class_own_traitssdCo+#**6X6<<> AsAt$A- qD   sAc||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 b|jdi|Dcic]}|t||c}Scc}w)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``. rS)rr)rurrs rU trait_valueszHasTraits.trait_values;s5(7Gd6F6F6R6RSdgdD))SSSs,cd|z}||jvr t||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)rrr.r)rur method_names rU_get_trait_default_generatorz&HasTraits._get_trait_default_generatorQs[ $d* $-- '4- - $..11 14>>;7 711$77rTc |D]8}|j|rtd|dt|jdt |dk(r@t |dk(r2t j t|j|d|S|jdi|}|j|i}|D]}|j||||<|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=rerPrrXrYrrrr)rurmrrnrdefaultss rUrzHasTraits.trait_defaults]s _A>>!$ 1QC'$;;A>tDHQK ErTc 8t|jdi|S)z2Get a list of all the names of this class' traits.rS)rr)rurs rUrzHasTraits.trait_namesssKDKK+(+,,rTc <|jj}t|dk(r|Si}|jD]\\}}|jD]?\}}t |s t |}||j j|dr?W|||<^|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)rurrrrr*rrs rUrzHasTraits.traitsws""$ x=A M!<<> %KD%(0(8 %$ 9 * +I 6I !3!3It!DE  % %t  % rTcR t|j|}d|zdz}t ||r*|t||vrt||j ||S|jj ||S#t$r+}td|jjd||d}~wwxYw)z%Get metadata values for trait by key.rr Nr~ _metadata)rr.rr=rPr rr)ru traitnamerrFr*r metadata_names rUtrait_metadatazHasTraits.trait_metadatas DNNI6E i+5 4 'C743O,O4/33CA A>>%%c73 3 0011NykZ  sA22 B&;&B!!B&c t||}|j|jDcic]\}}t||d|ur||c}}Scc}}w)zGet a dict of all event handlers defined on this class, not a parent. Works like ``event_handlers``, except for excluding traits from parents. N)rreventsrpr)rrrrnrr.s rUclass_own_trait_eventsz HasTraits.class_own_trait_eventss] Co**T*002 AsAt$A- qD   sAci}t|D]a\}}t|ts||||<||jvr|||<3t |ds@|jdi|j s]|||<c|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. tagsrS)rrdr)rr r,)rrr)rxrys rU trait_eventszHasTraits.trait_eventss|sO &DAq!\*< !F1IQ]]* !F1IQ'&s00$%q  & rTr)rr)rrrrr)rrkr"rr!rrrrj)rrrr)rt.Callable[..., t.Any]rSentinel | strrestr | Sentinelrr)rzt.Callable[..., t.Any] | Nonerr/rer0rr)NNF)rzEventHandler | NonerzSentinel | str | NonerrZrr)rr.rm+Sentinel | str | t.Iterable[Sentinel | str]rer/rr)rz str | t.Anyrr)rzt.Callable[..., None]rmztuple[str | Sentinel, ...]rr)rrrr)rrkrsrrr)rrrrr list[str])rrrrr"dict[str, TraitType[t.Any, t.Any]])rrkrrZ)rrrr)rrkrr)rmrkrrrzdict[str, t.Any] | Sentinel)rrrr2)rrrr3rW)r%rkrrkrFrrr)rrrrkrdict[str, EventHandler])rrrrrr4))rPrQrRrrrvrrpropertyrrrrr rrrrrrrJrrrrr classmethodr r rrrrrrrrr'r*r-rrs@rUr0r0"sV##&661122  #33 ?;z ."44$>3>3@  .)V "- "5C "KY "  " 4 A' 5' 5; 5 5  5J>A' 8'8;8 8  8214 "3,"35O"3 "3H &,22B    */  +    $*.T, 8,-> 4    rTr0ceZdZdZddZy)r"ze A trait with error reporting and string -> type resolution for Type, Instance and This. ct|S)zM Resolve a string supplied for a type into an actual object. r )rustrings rU_resolve_stringz#ClassBasedTraitType._resolve_strings6""rTNr9rkrrrPrQrRrr:rSrTrUr"r"s  #rTr"ceZdZdZej rej d ddZej d ddZej d ddZej d ddZedddddf dfd Zdd Z dd Z dd Z dd Z dd Z xZS)r@z? ?rT......)ruzType[type, type]rSentinel | None | strr@ None | strrLiteral[False]rrVrrr t.Any | Nonerrrr)ruzType[type | None, type | None]rrUr@rVr Literal[True]rrVrrrrXrrrr)ruz Type[S, S]rrr@rrrWrrVrrrrXrrrr)ruzType[S | None, S | None]rzS | Noner@rrrYrrVrrrrXrrrr)rrr@rrrZrrVrrrrXrrrrrrrsrrrrrr)rPrQrRrrX TYPE_CHECKINGrZrvrBrMr9rrPrUrrs@rUr@r@sF 47 #),%("#& " 0  '  #   !      47 #(+%("#& 0 0  &  #   !       #),%("#&    '  #   !      '*(+%("#& * #  &  #   !      ) !%#: : :  :  :  : : :  : x$  J @rTr@ceZdZUdZdZded<ejrej d ddZ ej d ddZ ej d ddZ ej d ddZ d dfd Z dd Z dd Z dd Z dd Z ddZddZddZxZS)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] | Noner@c yrWrSrur@rBkwrrrrs rUrvzInstance.__init__rArTc yrWrSr_s rUrvzInstance.__init__rArTc yrWrSr_s rUrvzInstance.__init__rArTc yrWrSr_s rUrvzInstance.__init__rArTc R| |j}|-tj|st|tr||_nt d|z|t|t s t d|t|ts t d||_||_ t|,d|||d|y)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) r@rrqrdrkr=rtuplerrrrrv) rur@rBr`rrrrr.s rUrvzInstance.__init__sL =JJE  GOOE$:jPS>TDJJURS S NJr4$8HI I  ju&=KL L   YJ)$YRXYrTc|jJ|jr||St||jrtjt |S|j ||yrW)r@rrdrXrYrrErs rUrMzInstance.validate sOzz%%% ??u}L eTZZ (66!U# # JJsE "rTct|jtrt|j}nt d|j}|j r|dz }|S)Nr=rM)rdr@rkrr r)rurs rUr9z Instance.info sD djj# & ,Fc4::.F ?? j F rTc$|jyrWrOrs rUrzInstance.instance_init rQrTczt|jtr!|j|j|_yyrW)rdr@rkr:r{s rUrPzInstance._resolve_classes s+ djj# &--djj9DJ 'rTc|j |jy|jJ|j|jxsdi|jxsiS)NrS)rrr@r{s rUrzInstance.make_dynamic_default sY    %D,?,?,Gzz%%%tzzD--3T9L9L9RPRTTrTc4t|jSrW)rTrr{s rUrUzInstance.default_value_repr! sD--/00rTcHtjtt|SrW)rXrYrrbrs rUrzInstance.from_string$ svva+A.//rTrT)ruz Instance[T]r@type[T]rBtuple[t.Any, ...] | Noner`dict[str, t.Any] | NonerrWrrVrrrrrr)ruzInstance[T | None]r@rmrBrnr`rorrYrrVrrrrrr)ruzInstance[t.Any]r@rrBrnr`rorrWrrVrrrrrr)ruzInstance[t.Any | None]r@rrBrnr`rorrYrrVrrrrrr)NNNFNN)r@r]rBrnr`rorrZrrVrrrrrrrrrsrrT | Nonerrr)rrqr]rkrrq)rPrQrRrr@rrXr[rZrvrMr9rrPrrUrrrs@rUr1r1s#'E & !-0*-),%("   + (  '  #       !-0*-(+%(" $  + (  &  #       !$-0*-),%(" !  + (  '  #       !$-0*-(+%(" (  + (  &  #      '+)-&* !%6Z#6Z'6Z $ 6Z  6Z  6Z6Z6Z 6Zp# :U 10rTr1ceZdZdZddZy)r,zC Mixin for forward-declared versions of Instance and Type. cf|jj}tdj||gS)z Find the specified class name by looking for it in the module in which our this_class attribute was defined. r)rrQr rC)rur9modnames rUr:z$ForwardDeclaredMixin._resolve_string- s, //,,388Wf$5677rTNr;r<rSrTrUr,r,( s 8rTr,ceZdZdZy)r-z+ Forward-declared version of Type. NrPrQrRrrSrTrUr-r-6 rTr-ceZdZdZy)r+z/ Forward-declared version of Instance. NrwrSrTrUr+r+< rxrTr+c0eZdZdZdZdfd ZddZxZS)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 Nonec $t|di|y)NrWrrrv)rurr.s rUrvz This.__init__L s ((rTcx|jJt||js||S|j||yrW)rrdrErs rUrMz This.validateO s9*** eT__ -%-L JJsE "rT)rrrr)rrrsrrrY)rPrQrRrrrvrMrrs@rUr<r<B sGI)#rTr<cbeZdZdZd fd Zd d fd Zd fd Zd dZddZddZ dfd Z xZ S)rCz'A trait type representing a Union type.c t||_dj|jDcgc]}|jc}|_t |di|ycc}w)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 NrS)rr4rCr9rrrrv)rur4rttr.s rUrvzUnion.__init__] sO8 ,$:J:J%KBbggi%KL "6"&LsAct||}|jD]}|tur|j|}|S|SrW)rrrFr4rB)rurrFr*r.s rUrFz Union.default} sK'/#&%% E)#--,   rTc~t|jD]}|j|dt| ||yrW)reversedr4rrr)rurr trait_typer.s rUrzUnion.class_init s<"4#3#34 -J  ! !#t , - 3%rTcZt|jD]}|j|yrW)rr4r)rurrs rUrzUnion.subclass_init s*"4#3#34 *J  $ $S ) *rTcP|j5|jD]T} |j||}|j't |d|jzdz|j |ccdddS ddd|j||y#t $rY~wxYw#1swY+xYw)Nr~r$)rr4r rrrr=rE)rurrsrrys rUrMzUnion.validate s  & & "..  ",,S%8Ayy,S499_{%BJDWDWXH     3"  s5BAB $B0B BBBBB%ct|tr"t|j|jzStg|j|SrWr3r5s rUr7z Union.__or__ sD eU #))E,=,==> >34++3U34 4rTc|jD]'} |j|}|jd|cSt ||S#ttf$rYJwxYwrW)r4rrMr=rarr)rur]rryr.s rUrzUnion.from_string sk** J **1-!**433  w"1%% +  s"AAA)r4rrrrrrW)rrrrrrrXrrrrrsrrr)r6rrrCr]rkrr) rPrQrRrrvrFrrrMr7rrrs@rUrCrCZ s/1#@& * 5 &&rTrCceZdZUdZej rej ddddd ddZej ddddd ddZej ddddd d  dd Z ddd dd d  dd Zej ddZej ddZddZd Z de d<dZ dZ ddZ y )rzA trait which allows any value..rrrrrXc yrWrSrurrrrrrs rUrvz Any.__init__ rArTc yrWrSrs rUrvz Any.__init__ rArTFN)rrrrc yrWrSrurrrrrrs rUrvz Any.__init__ rArTrc yrWrSrs rUrvz Any.__init__  rTcyrWrSrs rUrz Any.__get__  rTcyrWrSrs rUrz Any.__get__ rrTcyrWrSrs rUrz Any.__get__ s rTTrcyrWrSrs rUrzAny.subclass_init  rT).)rurrrrrWrrVrrrrXrrrr)rurrrrrYrrVrrrrXrrrr)rurrrrLiteral[True, False]rrrrVrrrrrr)rurrrrrZrrrrVrrrrrr)rrrrXrr)rrrrXrr)rrXrrXrz t.Any | Anyr)rPrQrRrrXr[rZrvrrrrrrrSrTrUrr s1) $'  &)"#&    '  #   !      $'  &)"#&    &  #   !      $' 03"%*     -    #      $'  %!%*         #             #'M<&JI rTrc F|jD||jkr5td|jdt|d|jd|d |jD||jkDr5td|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. zThe value of the 'rHz" instance should not be less than , but a value of z was specifiedz% instance should not be greater than )rr=rrr)r*rrss rU_validate_boundsr s yy!2  K G % {*;E7C    yy!2  K G##(99+->ugF   LrTc eZdZdZdZdZej d d dZej d ddZe ddddf dfd Zdd Z dd Z dd Z xZ S)r2z An int trait.rzan intc yrWrSrs rUrvz Int.__init__  rTc yrWrSrs rUrvz Int.__init__+ rrTFNc |jdd|_|jdd|_t|d|||||d|y)NrrrrrrrrS)rrrrrrvrurrrrrrr.s rUrvz Int.__init__7 sT::eT*::eT*  '!    rTct|ts|j||tjt t |||SrW)rdrrErXrYrrrs rUrMz Int.validateK s5%% JJsE "vva)$U;< ! 3rTc<|jr|dk(ryt|Sr)rrrs rUrzComplex.from_string s ??qF{qzrTcyrWrSrs rUrzComplex.subclass_init rrTNrrrsrrcomplex | None)r]rkrrr rPrQrRrrrrMrrrSrTrUr#r# s&M"I  rTr#ceZdZdZddZy)rz.A casting version of the complex number trait.c\ t|S#t$r|j||YywxYwrW)rrrErs rUrMzCComplex.validate s. #5> ! # JJsE " # ++NrrPrQrRrrMrSrTrUrr s 8#rTrc0eZdZdZdZdZddZd dZd dZy) rzA trait for byte strings.rTza bytes objectcLt|tr|S|j||yrW)rdbytesrErs rUrMzBytes.validate( s eU #L 3rTc|jr|dk(ryt|dk\r=dD]8}|ddd|k(s|d|k(s|}|dd}td|d|d td n|j d S) Nrrh"rrbr^zISupporting extra quotes around Bytes is deprecated in traitlets 5.0. Use instead of rrutf8)rrrrencode)rur]quoteold_ss rUrzBytes.from_string- s ??qF{ q6Q;# Ra5awK'AbEUNE!BA e<y;*#$   xxrTcyrWrSrs rUrzBytes.subclass_init? rrTNrrrsrr bytes | None)r]rkrrrrrSrTrUrr" s#M I  $ rTrceZdZdZddZy)rz+A casting version of the byte string trait.c\ t|S#t$r|j||YywxYwrW)rrrErs rUrMzCBytes.validateF s. #<  # JJsE " #rNrrrSrTrUrrC s 5#rTrceZdZdZdZdZejriej d d dZ ej d d dZ d ddZ ddZ ddZ dd Z y )rAzA trait for unicode strings.rza unicode stringc yrWrSrs rUrvzUnicode.__init__U rrTc yrWrSrs rUrvzUnicode.__init__a rrTc yrWrSrs rUrvzUnicode.__init__m rrTc xt|trtjt|St|t r+ tjt|j ddS|j||y#t$r7}d}t|j||jt||d}~wwxYw)Nasciistrictz=5.r) rrXrYrospath expanduserrrr)rur]rrs rUrzUnicode.from_string s ??qF{66!T? " GG  q ! q6Q; Q41R5%A%E!BA''(e<y@^`*#$  vva|rTcyrWrSrs rUrzUnicode.subclass_init rrTNr)ruzUnicode[str, str | bytes]rr0rrWrrVrrrrrrrr)ru'Unicode[str | None, str | bytes | None]rstr | Sentinel | NonerrYrrVrrrrrrrr)rurrrrrZrrVrrrrrrrrrZrr) rPrQrRrrrrXr[rZrvrMrrrSrTrUrArAM so&M"I -0),%(" + ) ' #          47(+%(" 9 0 & #         47"%(" 9 0  #        $ rTrAceZdZdZej riej d ddZej d d dZ d d dZd dZy) rz'A casting version of the unicode trait.c yrWrSrs rUrvzCUnicode.__init__ rrTc yrWrSrs rUrvzCUnicode.__init__ rrTc yrWrSrs rUrvzCUnicode.__init__ rrTc tjtt|S#t$r|j ||YywxYwrW)rXrYrrkrrErs rUrMzCUnicode.validate s9 #66!SZ( ( # JJsE " #"%AANr)ruzCUnicode[str, t.Any]rr0rrWrrVrrrrrrrr)ruCUnicode[str | None, t.Any]rrrrYrrVrrrrrrrr)rurrrrrZrrVrrrrrrrrrZrrSrTrUrr s[1 -0),%(" & ) ' #          47(+%(" - 0 & #         47"%(" - 0  #       #rTrc6eZdZdZdZedZddZddZy) 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|SrWrS)r~r]s rUrzObjectName. s1rTc|j||}t|tr t|r|S|j ||yrW) coerce_strrdrkr[rErs rUrMzObjectName.validate s6U+ eS !l5&9L 3rTc*|jr|dk(ry|Srrrs rUrzObjectName.from_string s ??qF{rTNrrrsrrrk)r]rkrr) rPrQrRrr staticmethodrrMrrSrTrUr8r8 s">6In-JrTr8ceZdZdZddZy)r'zFA string holding a valid dotted object name in Python, such as A.b3._cc|j||}t|tr#td|j dDr|S|j ||y)Nc32K|]}t|ywrW)r[)r>r=s rUr?z,DottedObjectName.validate.. s)Ta,q/)Tsr)rrdrkallrrErs rUrMzDottedObjectName.validate sEU+ eS !c)T5;;sCS)T&TL 3rTNrrrSrTrUr'r' s PrTr'c"eZdZdZdZdZejriej d d dZ ej d ddZ d ddZ ddZ ddZ dd Z dd Z y )rzA boolean (True, False) trait.Fz a booleanc yrWrSrs rUrvz Bool.__init__ rrTc yrWrSrs rUrvz Bool.__init__ rrTc yrWrSrs rUrvz Bool.__init__ rrTct|trtjt|St|t r>|dk(rtjtdS|dk(rtjtdS|j ||y)NrTrF)rdrZrXrYrrrErs rUrMz Bool.validate sd eT "66!U# # s #zvva&!vva'' 3rTc|jr|dk(rtjtdS|j }|dvrtjtdS|dvrtjtdSt d)Nr>1trueT>0falseFz%r is not 1, 0, true, or false)rrXrYrlowerrars rUrzBool.from_string sg ??qF{66!T? " GGI 66!T? " . 66!U# #=> >rTcyrWrSrs rUrzBool.subclass_init) rrTc Hgd}|jr|jd|S) Completion hints for argcomplete)r r rrr)rr)rur completionss rU argcompleterzBool.argcompleter, s"1 ??   v &rTNr)ruzBool[bool, bool | int]rbool | SentinelrrWrrVrrrrrrrr)ru$Bool[bool | None, bool | int | None]rbool | Sentinel | NonerrYrrVrrrrrrrr)rurrrrrZrrVrrrrrrrrrZrrrrrr2)rPrQrRrrrrXr[rZrvrMrrrrSrTrUrr st(MI .1),%(" ( * ' #          58(+%(" 6 1 & #         58"%(" 6 1  #        ? rTrceZdZdZej riej d ddZej d d dZ d d dZd dZy) rz'A casting version of the boolean trait.c yrWrSrs rUrvzCBool.__init__9 rrTc yrWrSrs rUrvzCBool.__init__E rrTc yrWrSrs rUrvzCBool.__init__Q rrTc tjtt|S#t$r|j ||YywxYwrW)rXrYrrZrrErs rUrMzCBool.validate\ s9 #66!T%[) ) # JJsE " #rNr)ruzCBool[bool, t.Any]rrrrWrrVrrrrrrrr)ruCBool[bool | None, t.Any]rrrrYrrVrrrrrrrr)rurrrrrZrrVrrrrrrrrrZrrSrTrUrr4 s[1 .1),%(" $ * ' #          58(+%(" + 1 & #         58"%(" + 1  #       #rTrcVeZdZdZej rTej d ddZej d ddZeddddf dfd ZddZ dddZ ddd Z dd Z dd Z dd Zdd ZddZxZS)r(z0An enum whose value must be in a given sequence.c yrWrSrurrrrrrrs rUrvz Enum.__init__h rArTc yrWrSr"s rUrvz Enum.__init__u rArTFNc x||_|dur |turd}||d<||d<||d<||d<t| |fi|y)NTrrrr)rrBrrrv) rurrrrrrrr.s rUrvz Enum.__init__ sY  -9"< M)|'{v!x 1&1rTc|jr(||jvrtjt|S|j ||yrW)rrXrYrrErs rUrMz Enum.validate s3 ;;5DKK/66!U# # 3rTc|jxsg}|rdjd|D}|Stt|}|S)6Returns a description of the trait choices (not none).|c3&K|] }d|z ywz``%r``NrSr>rs rUr?z$Enum._choices_str.. s!@1(Q,!@)rrCrTr)ruas_rstchoices choice_strs rU _choices_strzEnum._choices_str sE++# !@!@@Jd7m,JrTc\|jr d|rdndznd}d|j||SrL or %s`None`rrany of rr0rur-nones rU_infoz Enum._info 6>Booxv86:SU**623D6::rTc&|jdSNFr-r9r{s rUr9z Enum.info zzz''rTc&|jdSNTr=r>r{s rUinfo_rstz Enum.info_rst zzz&&rTc |jd|S#t$r&tjtt |cYSwxYwrW)rMr=rXrYrrbrs rUrzEnum.from_string s> 4==q) ) 466!/23 3 4s,AAcyrWrSrs rUrzEnum.subclass_init rrTc Z|jxsgDcgc] }t|c}Scc}w)r)rrk)rurrys rUrzEnum.argcompleter s# $ 1r21A222s(r)ruEnum[G]rz t.Sequence[G]rz G | SentinelrrWrrVrrrrrrrr)ruzEnum[G | None]rt.Sequence[G] | NonerG | Sentinel | NonerrYrrVrrrrrrrr)rurGrrHrrIrrZrrVrrrrrrrrrZFr-rZrrkrrrr)rPrQrRrrXr[rZrvrBrMr0r9r9rBrrrrrs@rUr(r(c s: +.),%("  ! ( '  #         25(+%("   ( / &  #        .7 !%22$2+2 2  2  222 2& ; ('4  3rTr(c\eZdZdZef dfd ZddZd d dZd dZd dZ xZ S) r!z4An enum of strings where the case should be ignored.c *t||fd|i|yNrr|)rurrrr.s rUrvzCaselessStrEnum.__init__ s G}GGrTc4t|ts|j|||jxsgD]Q}t|tsJ|j |j k(s7t j t|cS|j||yrW)rdrkrErrrXrYr)rurrsrys rUrMzCaselessStrEnum.validate sv%% JJsE "" $Aa% %%wwyEKKM)vva|# $ 3rTc^|jr d|rdndznd}d|j|d|S)rLr3r4rrr5z (case-insensitive)r6r7s rUr9zCaselessStrEnum._info s9>Booxv86:SU**6233FtfMMrTc&|jdSr<r>r{s rUr9zCaselessStrEnum.info r?rTc&|jdSrAr>r{s rUrBzCaselessStrEnum.info_rst rCrT) ruzCaselessStrEnum[t.Any]rrrrrrrrrZrJrKr) rPrQrRrrBrvrMr9r9rBrrs@rUr!r! sY> )H$HHH H  HN ('rTr!cpeZdZdZdZdZeddf dfd Zd dZd d dZ d dZ d dZ xZ S) r.zEAn case-ignoring enum matching choices by unique prefixes/substrings.Fc F||_||_t| |fd|i|yrN)case_sensitivesubstring_matchingrrrv)rurrrUrVrr.s rUrvzFuzzyEnum.__init__ s,-"4 G}GGrTc zt|ts|j|||jrdnd}|j}|rdnd}||}|j xsg}|Dcgc]}||||}}t |dk(rt||D] \} } | s | cS|j||ycc}w)Nc|SrWrSrs rUrz$FuzzyEnum.validate.. sqrTc"|jSrW)rrYs rUrz$FuzzyEnum.validate.. s  rTc ||vSrWrSryrs rUrz$FuzzyEnum.validate.. s 16rTc$|j|SrW) startswithr\s rUrz$FuzzyEnum.validate.. sTUT`T`abTcrTr)rdrkrErUrVrsumzip) rurrs conv_funcrV match_funcr.rmatchesryms rUrMzFuzzyEnum.validate s%% JJsE "%)%8%8[>Q !44.@)Gc % ++#Booxv86:SU"11{} $ 7 7X4&&d.?.?.G-HOOrTc&|jdSr<r>r{s rUr9zFuzzyEnum.info r?rTc&|jdSrAr>r{s rUrBzFuzzyEnum.info_rst rCrT)ruzFuzzyEnum[t.Any]rrrrrUrZrVrZrrrrrZrJrKr) rPrQrRrrUrVrBrvrMr9r9rBrrs@rUr.r. sON )$#( H H H H H ! H  H  H"P('rTr.ceZdZUdZdZded<dZded<eZdZ ded<d Z ded <e jd d d d  dd Z e jd d d d  ddZ e jd d d d d d ddZ dedddf dfd Z dfd ZddZdfd ZddZd dZd!dZd"d#dZxZS)$r$z\An instance of a container (list, set, etc.) To be subclassed by overriding klass. Nztype[T] | Noner@rSr _cast_types_trait)[]()_literal_from_string_pairs.rc yrWrSrurrrrrs rUrvzContainer.__init__ rrTc yrWrSrvs rUrvzContainer.__init__' rrT)r*rrrrc yrWrS)rur*rrrrrs rUrvzContainer.__init__3 s rTc p||turt|s|}d}|B|jdds0td|jj dt dt}|turd}nI|d}d|d <n?t||jr|f}n%td |jj d |t|rAt|trtd t d t|tr|n||_ n|tdt|zt|8d|j||||d|y)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=UndefinedrrrSrdefault value of  was rorhz'`trait` must be a Trait or None, got %s)r@rBrrr)rBrgrrr.rPrrd_valid_defaultsrlrerqr rrrvr@) rur*rrrrrrBr.s rUrvzContainer.__init__@ sKL  )!;HUO!ME  L%)H dnn5567//#  &M I %D  "D&*F? #  t';'; <!#D/0G0G/Hm_]^ ^ E?%&E&  &0t%<%'%DK  E RWHXXY Y  **4diPV Z` rTct||jr|jJ|j|}t|||}||S|j ||}t jt|SrW) rdrpr@rrrMvalidate_elementsrXrYrrurrsr.s rUrMzContainer.validate so eT-- .::) ))JJu%E e, =L&&sE2vvarTcg}|jt|jtrtjt |S|D]0} |jj ||}|j|2|jJ|j|S#t$r}|j|||Yd}~sd}~wwxYwrW) rqrdrrXrYrr rr=rEr@)rurrs validatedryrEs rUrzContainer.validate_elements s ;; *T[[#">66!U# # $A $KK))#q1  #  $zz%%%zz)$$  * 35)) *s B B= B88B=ct|jtr|jj|dt| ||yrW)rdrqr>rrrrs rUrzContainer.class_init s4 dkk9 - KK " "3 - 3%rTcpt|jtr|jj|yyrW)rdrqr>rrs rUrzContainer.subclass_init s' dkk9 - KK % %c * .rTct|tstd| t|}|j d|S#t$rd}YwxYw)Load value from a single stringzExpected string, got N)rdrkr=rrrMrur]rxs rUrzContainer.from_string sV!S!4QE:; ; ?D}}T4(( D s = A  A c jJt|dk(r|ddk(r jrytdk\rtfdjDrj rj j dz}nd}jJtd j|jztd jtStjj}d |jvr j}nddfd }jt!|Dcgc]\}}||| c}}Scc}}w)ziReturn the value from a list of config strings This is where we parse CLI configuration Nrrrrc3lK|]+\}}j|xrj|-ywrW)r^endswith)r>startendrs rUr?z-Container.from_string_list.. s6#E3 U#7 37#s14rrz}--{0}={1} for containers is deprecated in traitlets 5.0. You can pass `--{0} item` ... multiple times to add items to a list.rrcVtjtj|SrW)rXrYritem_from_string)r]rrus rUrz4Container.from_string_list..item_from_string svva!6!6q!9::rT)rrWr]rkrz int | NonerzT | str)r@rranyrtrrPrrrDrrr signaturer parameters enumerate)rus_listrsigridxr]rs` @rUfrom_string_listzContainer.from_string_list s> zz%%% v;! q AF{t1v{s#"&"A"A# ??"oo66 K#OFE(44ZZ "%"    #               ZZ "%"  !  "               ZZ"                     #(!%# P P P  P  P  P P  P d   %& + )' RrTr$ceZdZUdZeZefZded<de de jf d fd Z d dZ d fd Zd fd ZxZS) r4zAn instance of a Python list.rrpNrc F||_||_t| d||d|y)aCreate a List 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. minlen : Int [ default 0 ] The minimum length of the input list maxlen : Int [ default sys.maxsize ] The maximum length of the input list r*rNrS_maxlen_minlenrrrvrur*rminlenmaxlenrr.s rUrvz List.__init__ +D   LuMLVLrTczd|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=rJs rU length_errorzList.length_error!: myy(3-t||UK L mrTct|}||jks||jkDr|j||t|||SrWrrrrrrrrurrslengthr.s rUrzList.validate_elements(EU DLL FT\\$9   c5 )w(e44rTcft|trt| ||gSt| ||SrWrdrkrrr$rs rUr$zList.set/1 eS !7;sUG, ,7;sE* *rT) r*zIt.List[T] | t.Tuple[T] | t.Set[T] | Sentinel | TraitType[T, t.Any] | Nonerz3t.List[T] | t.Tuple[T] | t.Set[T] | Sentinel | Nonerrrrrrrrrrrsrrrr)rPrQrRrrr@rerprrBsysmaxsizervrrr$rrs@rUr4r4 s' EK!\`MVkk $MX$MK$M $M  $M  $M $ML5++rTr4ceZdZdZeZeefZdZ de de jf d fd Z d dZd fd Zd fd Zd d ZxZS)r:zAn instance of a Python set.)rrrsz{}Nrc F||_||_t| d||d|y)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 rUrvz Set.__init__?rrTczd|jt||j|j|fz}t |rrrJs rUrzSet.length_errorerrTct|}||jks||jkDr|j||t|||SrWrrs rUrzSet.validate_elementslrrTcft|trt| ||hSt| ||SrWrrs rUr$zSet.setsrrTcptt|jxsg}|dk(ryd|ddzdzS)Nrrzset(){rr^})rTrr)ru list_reprs rUrUzSet.default_value_reprys@ 9 9 ; ArBC  Yq_$s**rT) r*rrrrrrrrrrrrrr)rPrQrRrr$r@rerrprtrBrrrvrrrUrrs@rUr:r:6s& E$-K!3 (kk $M$M$M $M  $M  $M $ML5+ +rTr:cReZdZdZeZefZdfd ZddZ d dZ d fd Z d dZ xZ S) r?zAn instance of a Python tuple.c|jdt}t|dk(r|turt|ds|d}d}|B|j dds0t d|j jd td t}|turd}nI|d}d|d<n?t||jr|f}n%td |j jd |g|_ |D]F}t|trt dtd |}|jj|H|jr ||turd}tt |Fd|j$|d|y)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` rrrrSNrFrzr{rrr|r}~Traits should be given as instances, not types (for example, `Int()`, not `Int`) Passing types is deprecated in traitlets 4.1.r@rB)rrBrrgrrr.rPrrdr~rlrrerrrr$rvr@)rurrrrBr*r.s rUrvzTuple.__init__sn< ?I> v;!   :8FSTICV"1IMF  L%)H dnn5567//#  &M I %D  "D&*F? #  t';'; <!#D/0G0G/Hm_]^ ^  'E%&E&   LL   & ' <<]2my6PD i'NdjjtNvNrTc|jr|t|jk\r|S|j|j|Sr)rrrrs rUrzTuple.item_from_strings< ||uDLL(99H||E"..q11rTc|js|St|t|jk7rCd|jt|t|jt |fz}t |g}t |j|D])\}} |j||}|j|+t|S#t $r}|j|||Yd}~Xd}~wwxYw)NzTThe '%s' trait of %s instance requires %i elements, but a value of %s was specified.) rrrrr r=r`r rrEre)rurrsrrr*ryrEs rUrzTuple.validate_elementss||L u:T\\* *f99hsmS-> %@PQR Q-  DLL%0 $HE1 $OOC+  #  $Y  * 35)) *sC C( C##C(c|jD]%}t|ts|j|d'tt |||yrW)rrdr>rrrr$rurrr*r.s rUrzTuple.class_initsC\\ ,E%+  d+ , i)#t4rTcj|jD]$}t|ts|j|&yrW)rrdr>rrurr*s rUrzTuple.subclass_inits-\\ )E%+##C( )rT)rrrrrr)r]rkrrrrrrr)rPrQrRrrer@rrprvrrrrrrs@rUr?r?s.( E'KKOZ 2 *5 )rTr?ceZdZdZdZdZdddef d fd Z d ddZdfd Z ddZ dfd Z ddZ dd Z dd Zdd ZxZS)r&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``. Nc n|jdd}|!| td|}tdtd|jdd}|!| td|}td td|tur#|!t |st |trJ|}d}||t |r|}d}|turi}|d}n6t |tr|f}n"t |tr|f}ntd |zt |r1t |trtd td|}||_ n|td t|zt |r1t |trtd td|}||_ n|td t|z||_t |@dt|d|y)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()) r*NzFFound a value for both `value_trait` and its deprecated alias `trait`.zIKeyword `trait` is deprecated in traitlets 5.0, use `value_trait` insteadrrrzJFound 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)rrlrrrBrgrdr>rrre _value_traitr _key_trait_per_key_traitsrrrv) ru value_traitper_key_traits key_traitrrr*rrBr.s rUrvz Dict.__init__s\ 7D)  &\ K ["  Hd+  )`$N _"  I %+*AK(%k9=== + "  !;'* !% I %M  D  t ,!#D  } 5!#D:]JK K K +t,E&  *m +D   $?)KBXX  I )T*E&  &K 'DO  "IIV_L``a a- 9t$9&9rTc |d|jdt|d|jdt|d z}t |)Nz of the 'rHz instance must be rz was specified.)rrr9r r=)rurelement validatorsiders rU element_errorzDict.element_errorsm $))K >PQZQ_Q_QaPbbst}FuGtHHWX X mrTcPt|||}||S|j||SrW)rrrMrrs rUrMz Dict.validates1 e, =L%%c511rTc|jxsi}|j}|j}|s|s|s|Si}|D]H}||}|r |j||}|j ||} | r | j||}|||<J|j|S#t$r|j |||dY^wxYw#t$r|j ||| dYZwxYw)NKeysValues)rrrr r=rrr@) rurrsper_key_overriderrrrryactive_value_traits rUrzDict.validate_elementss//52OO '' [,<L  Cc AD#--c37C"2!5!5c;!G !M*44S!rrrrrrrs rUrzDict.class_inits d'' 3    ( (d 3 dooy 1 OO & &sD 1    +--446 ,  d+ , 3%rTcRt|jtr|jj|t|jtr|jj||j 1|j j D]}|j|yyrW)rdrr>rrrrrs rUrzDict.subclass_inits d'' 3    + +C 0 dooy 1 OO ) )# .    +--446 )##C( ) ,rTct|tstd|dt| t j d|j |gS#t$r!t|}t|tr|cYSwxYw)rz"from_string expects a string, got z of type dict[K, V]) rdrkrlrerXrYrrrbrrs rUrzDict.from_stringsx!S!@YtTUwiXY Y 66,(=(=qc(BC C %a(D$%   s%A&A<:A<c t|dk(r|ddk(r |jryt|dk(ri|djdrU|djdrAt d|j d|dd |j d t d t|dSi}|Dcgc]}|j|c}D]}|j||Scc}w) 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`. rrrNrrz--rz@ for dict-traits is deprecated in traitlets 5.0. You can pass --z7 ... multiple times to add items to a dict.rr) rrr^rrrrrrr)rurcombinedr]rs rUrzDict.from_string_lists v;! q V 3 v;! q 4 4S 9fQi>P>PQT>U TYYKq ,""&)),ce"   q * *4:;q$''*; A OOA   * ' #          58(+%(" L 1 & #         5>/4%)#  ; 2 -  #      %rTr;ceZdZdZdZddZy)rzA casting compiled regular expression trait. Accepts both strings and compiled regular expressions. The resulting attribute will be a compiled regular expression.za regular expressioncp tj|S#t$r|j||YywxYwrW)recompilerrErs rUrMzCRegExp.validate]s3 #::e$ $ # JJsE " #s 55N)rrrsrrzre.Pattern[t.Any] | NonerPrQrRrrrMrSrTrUrrUs8 'I#rTrzre.Pattern[t.Any]ceZdZUdZdZded<dZ d dfd ZefddZ efddZ dd Z ddd Z ddd Z dd Zdd ZxZS)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 classc *t|tjs Jd|z|jdd}|.|s,t t |j j}t|$dd|i|||_ |jdz|_ y)NzREQUIRE: enum.Enum, but was: %rrFrrrS) rfenumr(rnextiter __members__rrrrv enum_classrP name_prefix)rurrrrr.s rUrvzUseEnum.__init__s*dii0`2SV`2``0ZZ e4   j&<&<&C&C&E!FGM ?}??$%..4rTct|tsJ|jj}|j D]}|j |k(s|cS|S)z0Selects enum-value by using its number-constant.)rdrrrrrs)rursrF enum_members enum_items rUselect_by_numberzUseEnum.select_by_numbersR%%%%22 %,,. !I%'   !rTct|tsJ|j|jr|j |jdd}|j j j||S)z4Selects enum-value by using its name or scoped-name.rr)rdrkr^rreplacerrr)rursrFs rUselect_by_namezUseEnum.select_by_names[%%%%   D,, -MM$"2"2B:E**..ug>>rTc:t||jr|St|tr|j|}|turH|St|t r|j |}|tur|S||jry|jS|j||yrW) rdrrrrBrkrrrrE)rurrsvalue2s rUrMzUseEnum.validates eT__ -L s #**51FY& s #((/FY& ]))) 3rTc|jjj}|rdjd|DSt t |S)r'r(c3&K|] }d|z ywr*rSr+s rUr?z'UseEnum._choices_str..s:QHqL:r,)rrrNrCrTr)rur-r.s rUr0zUseEnum._choices_strsA//--224 88:':: :W & &rTc\|jr d|rdndznd}d|j||Sr2r6r7s rUr9z UseEnum._infor:rTc&|jdSr<r>r{s rUr9z UseEnum.infor?rTc&|jdSrAr>r{s rUrBzUseEnum.info_rstrCrTrW)rrXrrrrrr)rsrrFrrr)rsrkrFrrrrrJrKr)rPrQrRrrrrrvrBrrrMr0r9r9rBrrs@rUrDrDdst:'+M#*4I?C 5% 56; 5NS 5  5=F;D?('; ('rTrDceZdZdZdZddZy)r zxA trait which is callable. Notes ----- Classes are callable, as are instances with a __call__() method.z a callablecBt|r|S|j||yrW)rrErs rUrMzCallable.validates E?L JJsE "rTNrrrSrTrUr r s!I#rTr )r]rrrZr)rXrrrZ)rmr1rzt.Iterable[t.Any]rW)rrrrrzlist[tuple[str, t.Any]])rrrr)r`rrr\)rmr/rerkrr9)rrrr)rmr/rrE)rrkrr%)r*z'Int[t.Any, t.Any] | Float[t.Any, t.Any]rrrsrrr)r __future__rrrrrrrratypingrXastr utils.bunchrutils.descriptionsrrr r utils.getargspecr utils.importstringr utils.sentinelrutils.warningsrrrrrer$ frozensetrre ClassTypesr[typing_extensionsr__all__rBrNoDefaultSpecifiedrr=r[rbrgrLrprrrIrGrHrrrrrrrkrrrGenericr>r\rlr6r7rJrKrMrFr rr)r9rEr%r/r0r"r@r1r,r-r+Optionalr<rCrr2rr5rr3r*rrrrr#rrrrrArr8r'rrr(r!r.r$r4r:r?r&r;rrDrSrTrUr s!R#  JJ(+$@@uc9- W ??)< J      * Z 6  ( DLLLL^@E@EF 7 7 t CL CL CL ??/S!AQUU#A A( !Q$A(R !G!GH$6+6+rVL&VLr19,<#.L"B& R  'CJ!781>14=\=9l9>\>"1"Jg -g f #)AqD/ #c@ q!t $c@L]0"1a4(]0@ 8 8.QT  2HQK # qzz!}ajjm; <#0Q&IaeeQUUl #Q&rH )AJJquu%qzz!%%'88 9H V 29>GL 6= )AqD/= @-=3q!t9-=`4 e ? IadO? D-=U1a4[-=` i%) ,#w '155.1# IeUl # B#UIeQUUl+#I i1oI X,#wq!t}iQUU 3,#^38$,zH9QT?HV,#DAJ,#^V39QT?V3r'd1g'B/'Q/'dc cL>+9QVVAY >+BH+)AEE!%%L !H+V|)IaggaeeSj) *|)BN28L !N2b?%1a4?%D #i+QWW5H#5M-NNO #c'iquu %c'L#yCJ/CJ1GGH#rT