#NEWLINE# def explore_directories( start , exclude , ignore ) : #NEWLINE# #INDENT# 'Explore files and directories under `start`. `explore` and `ignore`\n    arguments are the same as in :func:`iter_filenames`.\n    ' #NEWLINE# e = '*[!p][!y]' #NEWLINE# exclude = ( '{0},{1}' . format ( e , exclude ) . split ( ',' ) if exclude else [ e ] ) #NEWLINE# ignore = ( '.*,{0}' . format ( ignore ) . split ( ',' ) if ignore else [ '.*' ] ) #NEWLINE# for ( root , dirs , files ) in os . walk ( start ) : #NEWLINE# #INDENT# dirs [ : ] = list ( filter_out ( dirs , ignore ) ) #NEWLINE# fullpaths = ( os . path . normpath ( os . path . join ( root , p ) ) for p in files ) #NEWLINE# for filename in filter_out ( fullpaths , exclude ) : #NEWLINE# #INDENT# if ( ( not os . path . basename ( filename ) . startswith ( '.' ) ) and filename . endswith ( '.py' ) ) : #NEWLINE# #INDENT# ( yield filename )