<s> """<STR_LIT>""" <EOL> __all__ = [ "<STR_LIT>" ] <EOL> from traits . api import Instance <EOL> from openmdao . main . variable import Variable , gui_excludes <EOL> class VarTree ( Variable ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , default_value , allow_none = True , ** metadata ) : <EOL> from openmdao . main . vartree import VariableTree <EOL> if isinstance ( default_value , VariableTree ) : <EOL> klass = default_value . __class__ <EOL> if '<STR_LIT>' in metadata : <EOL> default_value . _iotype = metadata [ '<STR_LIT>' ] <EOL> else : <EOL> metadata [ '<STR_LIT>' ] = default_value . iotype <EOL> else : <EOL> raise TypeError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> metadata . setdefault ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _allow_none = allow_none <EOL> self . klass = klass <EOL> self . _instance = Instance ( klass = klass , allow_none = False , factory = None , <EOL> args = None , kw = None , ** metadata ) <EOL> self . _instance . default_value = default_value <EOL> super ( VarTree , self ) . __init__ ( default_value , ** metadata ) <EOL> def validate ( self , obj , name , value ) : <EOL> """<STR_LIT>""" <EOL> if value is None : <EOL> if self . _allow_none : <EOL> return value <EOL> self . validate_failed ( obj , name , value ) <EOL> try : <EOL> value = self . _instance . validate ( obj , name , value ) <EOL> except Exception : <EOL> obj . raise_exception ( '<STR_LIT>' % <EOL> ( name , self . _instance . klass . __module__ , <EOL> self . _instance . klass . __name__ , type ( value ) ) , <EOL> TypeError ) <EOL> return value <EOL> def post_setattr ( self , obj , name , value ) : <EOL> """<STR_LIT>""" <EOL> if value . parent is not obj : <EOL> value . parent = obj <EOL> value . name = name <EOL> value . _iotype = self . iotype <EOL> def get_attribute ( self , name , value , trait , meta ) : <EOL> """<STR_LIT>""" <EOL> io_attr = { } <EOL> io_attr [ '<STR_LIT:name>' ] = name <EOL> io_attr [ '<STR_LIT:type>' ] = trait . trait_type . klass . __name__ <EOL> io_attr [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> for field in meta : <EOL> if field not in gui_excludes : <EOL> io_attr [ field ] = meta [ field ] <EOL> return io_attr , None </s>
