we would like to override some 'get' function with the following accession logic:
---- def get_value(self, object, name, trait=None): value = super(MultiPath, self).get_value(object, name, trait=trait)
if isdefined(value): # return contained element if length of stored list is 1 if isinstance(value, list) and len(value) == 1: return value return value
we could do this with a get/set function when the trait type was a List.
is there a way to do this with Either?
our typical usage scenario for the above is:
class A(HasTraits): foo = MultiPath(File(exists=True))
a = A() a.foo = '/path/to/existingfile.ext' or a.foo = glob('/path/to/existingfile*.ext')
if len(a.foo) == 1 it would return a string instead of a list.