Recursively scans a directory for all valid bot configs.
    :param root_dir: Directory to scan.
    :return: The set of bot configs that were found.
429665
def scan_directory_for_bot_configs(root_dir) -> Set[BotConfigBundle]:
    

    configs = set()

    for filename in glob.iglob(os.path.join(root_dir, '**/*.cfg'), recursive=True):
        try:
            bundle = get_bot_config_bundle(filename)
            configs.add(bundle)
        except (NoSectionError, MissingSectionHeaderError, NoOptionError, AttributeError, ParsingError, FileNotFoundError):
            pass

    return configs
927748
private static List<File> findFilesInDirectory(File directory,
			Pattern pattern, boolean scanRecursive) {
		List<File> files = new ArrayList<File>();
		String[] filesInDirectory = directory.list();
		if (filesInDirectory == null) {
			return files;
		}
		for (String fileToCheck : filesInDirectory) {
			File file = new File(directory, fileToCheck);
			if (file.isFile()) {
				if (pattern.matcher(fileToCheck).matches()) {
					files.add(file);
				}
			} else if (file.isDirectory()) {
				if (scanRecursive) {
					files.addAll(findFilesInDirectory(file, pattern,
							scanRecursive));
				}
			}
		}
		return files;
	}
556016
def main(self, *directories):
        
        if not self.git and len(directories) == 0:
            print ("ERROR: At least one directory must be provided (or the "
                   "--git-precommit flag must be passed.\n")
            self.help()
            return

        if len(directories) > 0:
            find = local['find']
            files = []
            for directory in directories:
                real = os.path.expanduser(directory)
                if not os.path.exists(real):
                    raise ValueError("{0} does not exist".format(directory))
                files.extend(find(real, '-name', '*.py').strip().split('\n'))
            if len(files) > 0:
                print "Linting {0} python files.\n".format(len(files))
                lint(files)
            else:
                print "No python files found to lint.\n"

        else:
            status = local['git']('status', '--porcelain', '-uno')
            root = local['git']('rev-parse', '--show-toplevel').strip()

            # get all modified or added python files
            modified = re.findall(r"^[AM]\s+\S+\.py$", status, re.MULTILINE)

            # now just get the path part, which all should be relative to the
            # root
            files = [os.path.join(root, line.split(' ', 1)[-1].strip())
                     for line in modified]
            if len(files) > 0:
                lint(files)
1190173
def in_dir(config_dir=CONFIG_DIR, extensions=['.yml', '.yaml', '.json']):
    
    configs = []

    for filename in os.listdir(config_dir):
        if is_config_file(filename, extensions) and not filename.startswith('.'):
            configs.append(filename)

    return configs
798442
def grep(rootdir, searched):
    ""
    to_inspect = []
    for root, dirs, files in os.walk(rootdir):
        for _file in files:
            if _file.endswith('.rst'):
                to_inspect.append(join(root, _file))

    to_check = ((_file, open(_file, 'r').read()) for _file in to_inspect)
    to_check = filter(lambda item: searched in item[1], to_check)
    to_check = map(lambda item: item[0], to_check)
    return to_check
1301198
private void scanForUnknownDirectories() {
      File[] filesInRoot = rootDirectory.listFiles();
      if (filesInRoot != null) {
         for (File maybeDirectory : filesInRoot) {
            if (maybeDirectory.isDirectory()) {
               String name = maybeDirectory.getName();
               try {
                  getDirectory(name);
               }
               catch (PersistenceException e) {
                  log.couldNotWalkDirectory(name, e);
               }
            }
         }
      }
   }
947253
def full_file_list(scan_path):
    
    file_list = []
    path = os.path.abspath(scan_path)
    for root, dirs, files in os.walk(path):
        if len(files) != 0 and not '.svn' in root and not '.git' in root:
            for f in files:
                file_list.append(os.path.join(root, f))
    return file_list
574317
def _root(name='', all_roots=False):
    '''
    
    '''
    if _sd_version() >= 219:
        if all_roots:
            return [os.path.join(x, name)
                    for x in ('/var/lib/machines', '/var/lib/container')]
        else:
            return os.path.join('/var/lib/machines', name)
    else:
        ret = os.path.join('/var/lib/container', name)
        if all_roots:
            return [ret]
        else:
            return ret
1075168
def _walk_directory(root_directory):
        

        paths = [os.path.join(root, name)
                 for root, dirs, files in os.walk(root_directory)  # noqa
                 for name in files]
        paths.sort()
        return paths
1081489
def get_admins_from_django(homedir):
    return ["root@localhost"]
    
    path = homedir + "/settings/basic.py"
    if not os.path.exists(path):
        path = homedir + "/settings.py"

    if not os.path.exists(path):
        return

    mod = compiler.parseFile(path)
    for node in mod.node.nodes:
        try:
            if node.asList()[0].name == "ADMINS":
                # print dir(node.asList()[1].nodes)
                # print node.asList()[1].nodes
                return [it.nodes[1].value for it in node.asList()[1].asList()]
        except:
            pass
851732
public static boolean deleteDirectoryTree( File dir )
    {
        File[] files = dir.listFiles();
        if (files == null) files = new File[0];
        for (File file : files)
        {
            deleteDirectoryTree( file );
        }
        return dir.delete();
    }
669860
def check_root(self):
        '''
        
        '''
        # No need to pass an environment to self.root() here since per-saltenv
        # configuration is a gitfs-only feature and check_root() is not used
        # for gitfs.
        root_dir = salt.utils.path.join(self.cachedir, self.root()).rstrip(os.sep)
        if os.path.isdir(root_dir):
            return root_dir
        log.error(
            'Root path \'%s\' not present in %s remote \'%s\', '
            'skipping.', self.root(), self.role, self.id
        )
        return None
1029349
def filter_dirs(root, dirs, excl_paths):
    
    filtered_dirs = []
    for dirpath in dirs:
        abspath = os.path.abspath(os.path.join(root, dirpath))
        if os.path.basename(abspath) in _SKIP_DIRS:
            continue
        if abspath not in excl_paths:
            filtered_dirs.append(dirpath)
    return filtered_dirs
1027477
def get_configs(self):
        
        self.check_configs_ready()

        result = []
        for bot in self.bots.values():
            result.extend(list(bot.get_models()))
        return result
931032
def discover(self, directory=None):
        
        directory = directory or self.patches_dir
        patches = []
        for root, dirs, files in os.walk(directory):
            for f in files:
                if not f.endswith('.py'):
                    continue
                name = f.rsplit('.', 1)[0]
                module = imp.load_source(name, '%s/%s' % (root, f))
                for elem in dir(module):
                    elem = getattr(module, elem)
                    if isinstance(elem, Patch):
                        patches.append(elem)

        def patch_key(patch):
            return tuple(int(i) for i in patch.target_version.split('.'))

        return sorted(patches, key=patch_key)
410399
def list_path(root_dir):
    
    res = []
    if os.path.isdir(root_dir):
        for name in os.listdir(root_dir):
            res.append(name)
    return res
421491
def list_dirs(directory):
    
    return [f for f in pathlib.Path(directory).iterdir() if f.is_dir()]