<commit_before># -*- coding: utf-8 -*-
import flask
import collections

__all__ = [
    'settings'
]


class Settings(collections.Mapping):
    """
    A proxy dictionary-like object that proxies to the current app
    configuration; or, if not in an active application context, pretends
    to be an empty dictionary.
    """

    def __getitem__(self, name):
        try:
            return flask.current_app.config[name]

        except RuntimeError:
            raise KeyError

    def __contains__(self, name):
        try:
            return name in flask.current_app.config

        except RuntimeError:
            return False

    def __len__(self):
        try:
            return len(flask.current_app.config)

        except RuntimeError:
            return 0

    def __iter__(self):
        try:
            return iter(flask.current_app.config)

        except:
            return iter(())

# Instantiate lazy-bound settings object.
settings = Settings()
<commit_msg>Expose alchemist settings as an object.<commit_after># -*- coding: utf-8 -*-
import flask
import collections

__all__ = [
    'settings'
]


class Settings(collections.Mapping):
    """
    A proxy dictionary-like object that proxies to the current app
    configuration; or, if not in an active application context, pretends
    to be an empty dictionary.
    """

    def __getattr__(self, name):
        try:
            return self[name]

        except KeyError:
            raise AttributeError

    def __getitem__(self, name):
        try:
            return flask.current_app.config[name]

        except RuntimeError:
            raise KeyError

    def __contains__(self, name):
        try:
            return name in flask.current_app.config

        except RuntimeError:
            return False

    def __len__(self):
        try:
            return len(flask.current_app.config)

        except RuntimeError:
            return 0

    def __iter__(self):
        try:
            return iter(flask.current_app.config)

        except:
            return iter(())

# Instantiate lazy-bound settings object.
settings = Settings()

{'fraction_non_alphanumeric': 0.0775375939849624, 'fraction_numerical': 0.0018796992481203006, 'mean_word_length': 2.0284495021337126, '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': '6053313', 'n_tokens_mistral': 584, 'n_tokens_neox': 551, 'n_words': 177}