def find_file(config_file=None, default_directories=None, default_bases=None):
if config_file:<EOL><INDENT>if path.exists(path.expanduser(config_file)):<EOL><INDENT>return config_file<EOL><DEDENT>else:<EOL><INDENT>raise FileNotFoundError('<STR_LIT>'.format(config_file))<EOL><DEDENT><DEDENT>dirs = default_directories or CONFIG_DIRS<EOL>dirs = [getcwd()] + dirs<EOL>bases = default_bases or CONFIG_BASES<EOL>for directory, base in product(dirs, bases):<EOL><INDENT>filepath = path.expanduser(path.join(directory, base))<EOL>if path.exists(filepath):<EOL><INDENT>return filepath<EOL><DEDENT><DEDENT>raise FileNotFoundError('<STR_LIT>'.format(dirs))<EOL>
Search for a config file in a list of files.