#NEWLINE# def enumerate_local_modules( tokens , path ) : #NEWLINE# #INDENT# '\n    Returns a list of modules inside *tokens* that are local to *path*.\n\n    **Note:**  Will recursively look inside *path* for said modules.\n    ' #NEWLINE# modules = enumerate_imports ( tokens ) #NEWLINE# local_modules = [ ] #NEWLINE# parent = '' #NEWLINE# for ( root , dirs , files ) in os . walk ( path ) : #NEWLINE# #INDENT# if ( not parent ) : #NEWLINE# #INDENT# parent = os . path . split ( root ) [ 1 ] #NEWLINE# #UNINDENT# for f in files : #NEWLINE# #INDENT# if f . endswith ( '.py' ) : #NEWLINE# #INDENT# f = f [ : ( - 3 ) ] #NEWLINE# module_tree = root . split ( parent ) [ 1 ] . replace ( '/' , '.' ) #NEWLINE# module_tree = module_tree . lstrip ( '.' ) #NEWLINE# if module_tree : #NEWLINE# #INDENT# module = ( '%s.%s' % ( module_tree , f ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# module = f #NEWLINE# #UNINDENT# if ( not ( module in modules ) ) : #NEWLINE# #INDENT# local_modules . append ( module ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return local_modules