<commit_before>#     Copyright 2020 Netflix, Inc.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.
import collections
import inspect
import json
import logging
import logging.config
import os
from typing import DefaultDict
from typing import List
from typing import Tuple

import import_string

from repokid.types import RepokidConfig
from repokid.types import RepokidHook
from repokid.types import RepokidHooks

__version__ = "0.17.0"


def init_config() -> RepokidConfig:
    """
    Try to find config by searching for it in a few paths, load it, and store it in the global CONFIG

    Args:
        account_number (string): The current account number Repokid is being run against. This is needed to provide
                                 the right config to the blocklist filter.

    Returns:
        None
    """
    load_config_paths = [
        os.path.join(os.getcwd(), "config.json"),
        "/etc/repokid/config.json",
        "/apps/repokid/config.json",
    ]
    config: RepokidConfig = {}
    for path in load_config_paths:
        try:
            with open(path, "r") as f:
                print("Loaded config from {}".format(path))
                config = json.load(f)
                return config

        except IOError:<commit_msg>Version 0.17.1<commit_after>#     Copyright 2020 Netflix, Inc.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.
import collections
import inspect
import json
import logging
import logging.config
import os
from typing import DefaultDict
from typing import List
from typing import Tuple

import import_string

from repokid.types import RepokidConfig
from repokid.types import RepokidHook
from repokid.types import RepokidHooks

__version__ = "0.17.1"


def init_config() -> RepokidConfig:
    """
    Try to find config by searching for it in a few paths, load it, and store it in the global CONFIG

    Args:
        account_number (string): The current account number Repokid is being run against. This is needed to provide
                                 the right config to the blocklist filter.

    Returns:
        None
    """
    load_config_paths = [
        os.path.join(os.getcwd(), "config.json"),
        "/etc/repokid/config.json",
        "/apps/repokid/config.json",
    ]
    config: RepokidConfig = {}
    for path in load_config_paths:
        try:
            with open(path, "r") as f:
                print("Loaded config from {}".format(path))
                config = json.load(f)
                return config

        except IOError:
{'fraction_non_alphanumeric': 0.07089031537817471, 'fraction_numerical': 0.007814680435389338, 'mean_word_length': 2.6129032258064515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '766413', 'n_tokens_mistral': 972, 'n_tokens_neox': 949, 'n_words': 400}