<commit_before># -*- coding: utf-8 -*-
import os.path
import sublime
import sublime_plugin

STVER = int(sublime.version())
ST3 = STVER >= 3000

# The one and only refernce to the GitGutter.sublime-settings file(s).
_package_settings = None


def get(key, default=None):
    """Get a value from GitGutter.sublime-settings.

    This function provides secure access to the package settings by loading
    the settings file on demand.

    Arguments:
        key (string): The setting to read.
        default (any): The value to return if 'key' is not available.

    Returns:
        any: The value from settings file if loaded and key exists or the
            default value provided from the caller.
    """
    global _package_settings
    if not _package_settings:
        _package_settings = sublime.load_settings('GitGutter.sublime-settings')
        if not _package_settings:
            return default
    return _package_settings.get(key, default)


class ViewSettings(object):
    """The class provides a layer to merge view and package settings.

    The ViewSettings class provides a common interface to support
    view or project based GitGutter settings. All settings found in the
    GitGutter.sublime-settings file can be placed in Preferences or the
    settings of a *.sublime-project file as well by simply prepending the
    'git_gutter_'. This even allows temporary changes for single views.

    Note:
        The only exception is 'git_binary' setting, which is NOT prefixed.
        It is searched in all settings files as 'git_binary'.

    Example:
        GitGutter.sublime-settings
        {
            show_in_minimap: 3
        }

        Preferences.sublime-settings
        {
            git_gutter_show_in_minimap: 3
        }

        Project.sublime-project
        {
            ...
            settings:
            {<commit_msg>Internal: Cache global settings as function attribute<commit_after># -*- coding: utf-8 -*-
import os.path
import sublime
import sublime_plugin

STVER = int(sublime.version())
ST3 = STVER >= 3000


def get(key, default=None):
    """Get a value from GitGutter.sublime-settings.

    This function provides secure access to the package settings by loading
    the settings file on demand.

    Arguments:
        key (string): The setting to read.
        default (any): The value to return if 'key' is not available.

    Returns:
        any: The value from settings file if loaded and key exists or the
            default value provided from the caller.
    """
    try:
        settings = get.settings
    except AttributeError:
        settings = sublime.load_settings('GitGutter.sublime-settings')
        get.settings = settings
    return settings.get(key, default)


class ViewSettings(object):
    """The class provides a layer to merge view and package settings.

    The ViewSettings class provides a common interface to support
    view or project based GitGutter settings. All settings found in the
    GitGutter.sublime-settings file can be placed in Preferences or the
    settings of a *.sublime-project file as well by simply prepending the
    'git_gutter_'. This even allows temporary changes for single views.

    Note:
        The only exception is 'git_binary' setting, which is NOT prefixed.
        It is searched in all settings files as 'git_binary'.

    Example:
        GitGutter.sublime-settings
        {
            show_in_minimap: 3
        }

        Preferences.sublime-settings
        {
            git_gutter_show_in_minimap: 3
        }

        Project.sublime-project
        {
            ...
            settings:
            {
{'fraction_non_alphanumeric': 0.06320417697169552, 'fraction_numerical': 0.004396812311074471, 'mean_word_length': 2.4502369668246446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5961267', 'n_tokens_mistral': 1003, 'n_tokens_neox': 956, 'n_words': 378}