<commit_before># -*- coding: utf-8 -*-

import yaml
from blackgate.errors import InvalidConfig

def verify_proxy(conf):
    if not conf.get('proxies'):
        return
    for proxy in conf.get('proxies'):
        if 'upstream_url' not in proxy:
            raise InvalidConfig('Missing Upstream URL, example: `upstream_url: http://service.com`')
        if 'name' not in proxy:
            raise InvalidConfig('Missing Upstream Name, example: `name: myservice')



def parse_yaml_config(config):
    try:
        return yaml.load(config)
    except ValueError:
        raise InvalidConfig('Broken YAML config.')<commit_msg>define read_default_config.<commit_after># -*- coding: utf-8 -*-

import os
import yaml
from blackgate.errors import InvalidConfig

def verify_proxy(conf):
    if not conf.get('proxies'):
        return
    for proxy in conf.get('proxies'):
        if 'upstream_url' not in proxy:
            raise InvalidConfig('Missing Upstream URL, example: `upstream_url: http://service.com`')
        if 'name' not in proxy:
            raise InvalidConfig('Missing Upstream Name, example: `name: myservice')



def parse_yaml_config(config):
    try:
        return yaml.load(config)
    except ValueError:
        raise InvalidConfig('Broken YAML config.')


def read_yaml_config(path):
    try:
        with open(path) as f:
            return f.read()
    except IOError:
        pass

def read_default_config():
    config = (
        read_yaml_config(os.path.join(os.getcwd(), 'blackgate.yml')) or \
        read_yaml_config(os.path.join(os.getlogin(), '.blackgate.yml')) or \
        read_yaml_config(os.path.join('usr', 'local', 'etc', 'blackgate', 'blackgate.yml')) or \
        read_yaml_config(os.path.join('etc', 'blackgate', 'blackgate.yml'))
    )
    return config
{'fraction_non_alphanumeric': 0.12283640424343942, 'fraction_numerical': 0.0011166945840312675, 'mean_word_length': 2.9733924611973395, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7514743', 'n_tokens_mistral': 553, 'n_tokens_neox': 538, 'n_words': 142}