import os


def get_all_names(file, ignorelist):
    objects= os.listdir()

    for obj in objects:
        if obj not in ignorelist:
            if os.path.isdir(obj):
                file.write('/' + obj + '\r\n') 
                print('/', obj, sep='')
                os.chdir(obj)
                get_all_names(file, ignorelist)
            else:
                file.write('    ' + obj + '\r\n')
                print('     ', obj)
    os.chdir("../")



def main():
    os.chdir("../")
    file = open('names.txt', 'w+')
    get_all_names(file, ('.git', 'doc', 'tools', 'project'))
    file.close()

if __name__ == '__main__':
    main()
