def _crawl_config_files(
        self,
        root_dir='/',
        exclude_dirs=['proc', 'mnt', 'dev', 'tmp'],
        root_dir_alias=None,
        known_config_files=[],
        discover_config_files=False,
    ):

        assert(self.crawl_mode is not Modes.OUTCONTAINER)

        saved_args = locals()
        logger.debug('Crawling config files: %s' % (saved_args))
        accessed_since = self.feature_epoch
        try:
            assert os.path.isdir(root_dir)
            if root_dir_alias is None:
                root_dir_alias = root_dir
            exclude_dirs = [os.path.join(root_dir, d) for d in
                            exclude_dirs]
            exclude_regex = r'|'.join([fnmatch.translate(d) for d in
                                       exclude_dirs]) or r'$.'
            known_config_files[:] = [os.path.join(root_dir, f) for f in
                                     known_config_files]
            known_config_files[:] = [f for f in known_config_files
                                     if not re.match(exclude_regex, f)]
            config_file_set = set()
            for fpath in known_config_files:
                if os.path.exists(fpath):
                    lstat = os.lstat(fpath)
                    if (lstat.st_atime > accessed_since or
                            lstat.st_ctime > accessed_since):
                        config_file_set.add(fpath)
        except Exception as e:
            logger.error('Error examining %s' % root_dir, exc_info=True)
            raise CrawlError(e)
        try:
            if discover_config_files:

                # Walk the directory hierarchy starting at 'root_dir' in BFS
                # order looking for config files.

                for (root_dirpath, dirs, files) in os.walk(root_dir):
                    dirs[:] = [os.path.join(root_dirpath, d) for d in
                               dirs]
                    dirs[:] = [d for d in dirs
                               if not re.match(exclude_regex, d)]
                    files = [os.path.join(root_dirpath, f) for f in
                             files]
                    files = [f for f in files
                             if not re.match(exclude_regex, f)]
                    for fpath in files:
                        if os.path.exists(fpath) \
                                and self.is_config_file(fpath):
                            lstat = os.lstat(fpath)
                            if lstat.st_atime > accessed_since \
                                    or lstat.st_ctime > accessed_since:
                                config_file_set.add(fpath)
        except Exception as e:
            logger.error('Error examining %s' % root_dir, exc_info=True)
            raise CrawlError(e)
        try:
            for fpath in config_file_set:
                try:
                    (_, fname) = os.path.split(fpath)
                    frelpath = fpath.replace(root_dir, root_dir_alias,
                                             1)  # root_dir relative path

            # Copy this config_file into / before reading it, so we
            # don't change its atime attribute.

                    (th, temppath) = tempfile.mkstemp(prefix='config.',
                                                      dir='/')
                    os.close(th)
                    shutil.copyfile(fpath, temppath)
                    with codecs.open(filename=fpath, mode='r',
                                     encoding='utf-8', errors='ignore') as \
                            config_file:

                        # Encode the contents of config_file as utf-8.

                        yield (frelpath, ConfigFeature(fname,
                                                       config_file.read(),
                                                       frelpath))
                    os.remove(temppath)
                except __HOLE__ as e:
                    raise CrawlError(e)
                except Exception as e:
                    logger.error('Error crawling config file %s'
                                 % fpath, exc_info=True)
                    raise CrawlError(e)
        except Exception as e:
            logger.error('Error examining %s' % root_dir, exc_info=True)
            raise CrawlError(e)

    # crawl disk partition information
dataset/ETHPy150Open cloudviz/agentless-system-crawler/crawler/features_crawler.py/FeaturesCrawler._crawl_config_files