<commit_before>"""default mixins for IntegrationMixins"""
from django.conf.urls import url, include

from plugin.urls import PLUGIN_BASE


class GlobalSettingsMixin:
    """Mixin that enables global settings for the plugin"""
    class MixinMeta:
        """meta options for this mixin"""
        MIXIN_NAME = 'Global settings'

    def __init__(self):
        super().__init__()
        self.add_mixin('globalsettings', 'has_globalsettings', __class__)
        self.globalsettings = self.setup_globalsettings()

    def setup_globalsettings(self):
        """
        setup global settings for this plugin
        """
        return getattr(self, 'GLOBALSETTINGS', None)

    @property
    def has_globalsettings(self):
        """
        does this plugin use custom global settings
        """
        return bool(self.globalsettings)

    @property
    def globalsettingspatterns(self):
        """
        get patterns for InvenTreeSetting defintion
        """
        if self.has_globalsettings:
            return {f'PLUGIN_{self.slug.upper()}_{key}': value for key, value in self.globalsettings.items()}
        return None

    def _globalsetting_name(self, key):
        """get global name of setting"""
        return f'PLUGIN_{self.slug.upper()}_{key}'

    def get_globalsetting(self, key):
        """
        get plugin global setting by key
        """
        from common.models import InvenTreeSetting<commit_msg>getattr should look for "SETTINGS" and not "GLOBALSETTINGS"<commit_after>"""
Plugin mixin classes
"""

from django.conf.urls import url, include

from plugin.urls import PLUGIN_BASE


class GlobalSettingsMixin:
    """
    Mixin that enables global settings for the plugin
    """
    
    class MixinMeta:
        MIXIN_NAME = 'Settings'

    def __init__(self):
        super().__init__()
        self.add_mixin('globalsettings', 'has_globalsettings', __class__)
        self.globalsettings = self.setup_globalsettings()

    def setup_globalsettings(self):
        """
        setup global settings for this plugin
        """
        return getattr(self, 'SETTINGS', None)

    @property
    def has_globalsettings(self):
        """
        does this plugin use custom global settings
        """
        return bool(self.globalsettings)

    @property
    def globalsettingspatterns(self):
        """
        get patterns for InvenTreeSetting defintion
        """
        if self.has_globalsettings:
            return {f'PLUGIN_{self.slug.upper()}_{key}': value for key, value in self.globalsettings.items()}
        return None

    def _globalsetting_name(self, key):
        """get global name of setting"""
        return f'PLUGIN_{self.slug.upper()}_{key}'

    def get_globalsetting(self, key):
        """
        get plugin global setting by key
        """
        from common.models import InvenTreeSetting
{'fraction_non_alphanumeric': 0.09800490024501225, 'fraction_numerical': 0.0, 'mean_word_length': 2.6500638569604087, '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': '969327', 'n_tokens_mistral': 775, 'n_tokens_neox': 797, 'n_words': 216}