<s> import os <EOL> import fnmatch <EOL> import yaml <EOL> from log import log <EOL> def get_node_info ( node_dir , node_name ) : <EOL> """<STR_LIT>""" <EOL> log . debug ( '<STR_LIT>' ) <EOL> result = _descend ( node_dir , node_name ) <EOL> result . sort ( lambda x , y : cmp ( <EOL> len ( os . path . basename ( x ) . translate ( None , '<STR_LIT>' ) ) , <EOL> len ( os . path . basename ( y ) . translate ( None , '<STR_LIT>' ) ) ) ) <EOL> ret = { } <EOL> for r in result : <EOL> with open ( r ) as node_file : <EOL> ret . update ( yaml . load ( node_file . read ( ) ) ) <EOL> log . debug ( '<STR_LIT>' , ret ) <EOL> return ret <EOL> def _descend ( base_dir , node_name ) : <EOL> """<STR_LIT>""" <EOL> files = os . listdir ( base_dir ) <EOL> result = [ ] <EOL> for f in files : <EOL> srcfile = os . path . join ( base_dir , f ) <EOL> if os . path . isdir ( srcfile ) : <EOL> result . extend ( _descend ( srcfile , node_name ) ) <EOL> else : <EOL> if fnmatch . filter ( [ node_name ] , f . replace ( '<STR_LIT:%>' , '<STR_LIT:*>' ) ) : <EOL> result . append ( srcfile ) <EOL> return result </s>
