@@ -489,14 +489,19 @@ class Either(TraitType):
489489
490490 def __init__ (self , * traits , ** metadata ):
491491 """Create a trait whose value can be any of of a specified list of traits."""
492- metadata [ 'alternatives' ] = tuple (trait_from (t ) for t in traits )
492+ _either_traits = tuple (trait_from (t ) for t in traits )
493493 self .trait_maker = _TraitMaker (
494494 metadata .pop ("default" , None ), * traits , ** metadata )
495+ self .either_traits = _either_traits
495496
496497 def as_ctrait (self ):
497498 """Return a CTrait corresponding to the trait defined by this class."""
498499 return self .trait_maker .as_ctrait ()
499500
501+ def inner_traits (self ):
502+ """Return the *inner trait* (or traits) for this trait."""
503+ return self .either_traits
504+
500505
501506traits .Tuple = Tuple
502507traits .Either = Either
@@ -550,14 +555,14 @@ def _recurse_on_path_traits(func, thistrait, value, cwd):
550555 elif thistrait .is_trait_type (Tuple ):
551556 value = tuple ([_recurse_on_path_traits (func , subtrait , v , cwd )
552557 for subtrait , v in zip (thistrait .inner_traits , value )])
553- elif thistrait .alternatives :
558+ elif thistrait .is_trait_type ( Either ) :
554559 is_str = [f .is_trait_type ((traits .String , traits .BaseStr , traits .BaseBytes , Str ))
555- for f in thistrait .alternatives ]
560+ for f in thistrait .inner_traits ]
556561 if any (is_str ) and isinstance (value , (bytes , str )) and not value .startswith ('/' ):
557562 return value
558- is_basepath = [f .is_trait_type (BasePath ) for f in thistrait .alternatives ]
563+ is_basepath = [f .is_trait_type (BasePath ) for f in thistrait .inner_traits ]
559564 if any (is_basepath ):
560- subtrait = thistrait .alternatives [is_basepath .index (True )]
565+ subtrait = thistrait .inner_traits [is_basepath .index (True )]
561566 value = _recurse_on_path_traits (func , subtrait , value , cwd )
562567 return value
563568
0 commit comments