<commit_before># -*- coding: utf8 -*-
"""
pybossa-discourse
-----------------

A PyBossa plugin for Discourse integration.
"""

import os
import inspect
from flask import current_app as app
from flask.ext.plugins import Plugin
from .client import DiscourseClient
from .sso import DiscourseSSO

__plugin__ = "PyBossaDiscourse"
__version__ = "0.1.0"

DISCOURSE_SETTINGS = ('DISCOURSE_API_KEY',
                      'DISCOURSE_API_USERNAME',
                      'DISCOURSE_SECRET',
                      'DISCOURSE_DOMAIN',
                      'DISCOURSE_PYBOSSA_IP',
                      'DISCOURSE_AUTO_UPDATE_SETTINGS')


class PyBossaDiscourse(Plugin):
    """PyBossa Discourse plugin class."""


    def setup(self):
        """Setup the plugin."""

        # Check all settings are provided
        for setting in DISCOURSE_SETTINGS:
            value = app.config.get(setting)
            if not value:
                raise ValueError('{} setting not found.'.format(setting))

        # Application specific state
        app.extensions['discourse'] = {'client': None, 'sso': None}

        self.setup_client()
        self.setup_sso()
        self.setup_global_envars()
        self.setup_blueprint()
        if app.config['DISCOURSE_AUTO_UPDATE_SETTINGS']:
            self.setup_discourse()


    def setup_client(self):
        """Setup the Discourse client."""
        app.extensions['discourse']['client'] = DiscourseClient(app)<commit_msg>Change test for existing settings<commit_after># -*- coding: utf8 -*-
"""
pybossa-discourse
-----------------

A PyBossa plugin for Discourse integration.
"""

import os
import inspect
from flask import current_app as app
from flask.ext.plugins import Plugin
from .client import DiscourseClient
from .sso import DiscourseSSO

__plugin__ = "PyBossaDiscourse"
__version__ = "0.1.0"

DISCOURSE_SETTINGS = ('DISCOURSE_API_KEY',
                      'DISCOURSE_API_USERNAME',
                      'DISCOURSE_SECRET',
                      'DISCOURSE_DOMAIN',
                      'DISCOURSE_PYBOSSA_IP',
                      'DISCOURSE_AUTO_UPDATE_SETTINGS')


class PyBossaDiscourse(Plugin):
    """PyBossa Discourse plugin class."""


    def setup(self):
        """Setup the plugin."""

        # Check all settings are provided
        for setting in DISCOURSE_SETTINGS:
            try:
                app.config[setting]
            except KeyError:
                raise ValueError('{} setting not found.'.format(setting))

        # Application specific state
        app.extensions['discourse'] = {'client': None, 'sso': None}

        self.setup_client()
        self.setup_sso()
        self.setup_global_envars()
        self.setup_blueprint()
        if app.config['DISCOURSE_AUTO_UPDATE_SETTINGS']:
            self.setup_discourse()


    def setup_client(self):
        """Setup the Discourse client."""
        app.extensions['discourse']['client'] = DiscourseClient(app)
{'fraction_non_alphanumeric': 0.11167684996605567, 'fraction_numerical': 0.0027155465037338763, 'mean_word_length': 2.3186936936936937, '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': '4912734', 'n_tokens_mistral': 876, 'n_tokens_neox': 843, 'n_words': 194}