#NEWLINE# @ classmethod #NEWLINE# def from_yaml( cls , f , resolve_imports = True ) : #NEWLINE# #INDENT# '\n        Returns an AttrDict initialized from the given path or\n        file object ``f``, which must point to a YAML file.\n\n        If ``resolve_imports`` is True, ``import:`` statements are\n        resolved recursively, else they are treated like any other key.\n\n        When resolving import statements, anything defined locally\n        overrides definitions in the imported file.\n\n        ' #NEWLINE# if isinstance ( f , str ) : #NEWLINE# #INDENT# with open ( f , 'r' ) as src : #NEWLINE# #INDENT# loaded = cls ( yaml . load ( src ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# loaded = cls ( yaml . load ( f ) ) #NEWLINE# #UNINDENT# if ( resolve_imports and ( 'import' in imported ) ) : #NEWLINE# #INDENT# for k in loaded [ 'import' ] : #NEWLINE# #INDENT# imported = cls . from_yaml ( relative_path ( k , f ) ) #NEWLINE# imported . union ( loaded ) #NEWLINE# loaded = imported #NEWLINE# #UNINDENT# loaded . pop ( 'import' , None ) #NEWLINE# #UNINDENT# return loaded