<commit_before>import json
import logging
from os.path import abspath, expanduser, splitext

import yaml

logger = logging.getLogger(__name__)


def read(*paths):
    any_found = False
    for path in paths:
        path = abspath(expanduser(path.strip()))
        ext = splitext(path)[1][1:]
        try:
            if ext in {'yml', 'yaml'}:
                with open(path, 'r') as fd:
                    yield path, ext, yaml.load(fd.read())
            elif ext == 'json':
                with open(path, 'r') as fd:
                    yield path, ext, json.load(fd)
            else:
                logger.error("File %r ignored: unknown type (%s)", path, ext)
                continue
            any_found = True
        except FileNotFoundError:
            logger.debug('%r not found', path)
        except PermissionError:
            logger.warning('%r: no right to read', path)
    if not any_found:
        logger.warning('no file found among %r', paths)


def _extract_value(config, path):
    if path[0] in config and len(path) == 1:
        return config[path[0]]<commit_msg>Removing warning from yaml<commit_after>import json
import logging
from os.path import abspath, expanduser, splitext

import yaml

logger = logging.getLogger(__name__)


def read(*paths):
    any_found = False
    for path in paths:
        path = abspath(expanduser(path.strip()))
        ext = splitext(path)[1][1:]
        try:
            if ext in {'yml', 'yaml'}:
                with open(path, 'r') as fd:
                    yield path, ext, yaml.load(fd.read(),
                                               Loader=yaml.FullLoader)
            elif ext == 'json':
                with open(path, 'r') as fd:
                    yield path, ext, json.load(fd)
            else:
                logger.error("File %r ignored: unknown type (%s)", path, ext)
                continue
            any_found = True
        except FileNotFoundError:
            logger.debug('%r not found', path)
        except PermissionError:
            logger.warning('%r: no right to read', path)
    if not any_found:
        logger.warning('no file found among %r', paths)


def _extract_value(config, path):
    if path[0] in config and len(path) == 1:
        return config[path[0]]
{'fraction_non_alphanumeric': 0.11125769569041337, 'fraction_numerical': 0.0043975373790677225, 'mean_word_length': 1.8688524590163935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7345984', 'n_tokens_mistral': 661, 'n_tokens_neox': 631, 'n_words': 203}