<commit_before>from portality.core import app
from portality.lib import plugin

from portality.events.consumers.account_created_email import AccountCreatedEmail
from portality.events.consumers.application_assed_inprogress_notify import ApplicationAssedInprogressNotify
from portality.events.consumers.application_assed_assigned_notify import ApplicationAssedAssignedNotify
from portality.events.consumers.bg_job_finished_notify import BGJobFinishedNotify
from portality.events.consumers.application_maned_ready_notify import ApplicationManedReadyNotifyg
from portality.events.consumers.application_publisher_created_notify import ApplicationPublisherCreatedNotify
from portality.events.consumers.application_publisher_revision_notify import ApplicationPublisherRevisionNotify
from portality.events.consumers.application_editor_completed_notify import ApplicationEditorCompletedNotify
from portality.events.consumers.application_editor_inprogress_notify import ApplicationEditorInProgressNotify
from portality.events.consumers.account_passwordreset_email import AccountPasswordResetEmail
from portality.events.consumers.application_editor_group_assigned_notify import ApplicationEditorGroupAssignedNotify
from portality.events.consumers.application_publisher_accepted_notify import ApplicationPublisherAcceptedNotify
from portality.events.consumers.update_request_publisher_accepted_notify import UpdateRequestPublisherAcceptedNotify
from portality.events.consumers.application_publisher_assigned_notify import ApplicationPublisherAssignedNotify
from portality.events.consumers.update_request_publisher_assigned_notify import UpdateRequestPublisherAssignedNotify
from portality.events.consumers.journal_assed_assigned_notify import JournalAssedAssignedNotify
from portality.events.consumers.journal_editor_group_assigned_notify import JournalEditorGroupAssignedNotify


class EventsService(object):
    EVENT_CONSUMERS = [
        # AccountCreatedEmail,
        # AccountPasswordResetEmail,
        # ApplicationAssedInprogressNotify,
        # ApplicationAssedAssignedNotify,
        # ApplicationEditorCompletedNotify,
        # ApplicationEditorInProgressNotify,
        # ApplicationEditorGroupAssignedNotify,
        # ApplicationManedReadyNotify,
        # ApplicationPublisherAcceptedNotify,
        # ApplicationPublisherAssignedNotify,
        # BGJobFinishedNotify,
        # ApplicationPublisherCreatedNotify,
        # ApplicationPublisherRevisionNotify,
        # JournalAssedAssignedNotify,
        # JournalEditorGroupAssignedNotify,
        # UpdateRequestPublisherAcceptedNotify,
        # UpdateRequestPublisherAssignedNotify
    ]

    def __init__(self):
        self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION"))

    def trigger(self, event):
        self.trigger_function(event)

    def consume(self, event):
        for consumer in self.EVENT_CONSUMERS:
            try:
                if consumer.consumes(event):
                    consumer.consume(event)
            except Exception as e:
                app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))<commit_msg>Update events.py<commit_after>from portality.core import app
from portality.lib import plugin

from portality.events.consumers.account_created_email import AccountCreatedEmail
from portality.events.consumers.application_assed_inprogress_notify import ApplicationAssedInprogressNotify
from portality.events.consumers.application_assed_assigned_notify import ApplicationAssedAssignedNotify
from portality.events.consumers.bg_job_finished_notify import BGJobFinishedNotify
from portality.events.consumers.application_maned_ready_notify import ApplicationManedReadyNotifyg
from portality.events.consumers.application_publisher_created_notify import ApplicationPublisherCreatedNotify
from portality.events.consumers.application_publisher_revision_notify import ApplicationPublisherRevisionNotify
from portality.events.consumers.application_editor_completed_notify import ApplicationEditorCompletedNotify
from portality.events.consumers.application_editor_inprogress_notify import ApplicationEditorInProgressNotify
from portality.events.consumers.account_passwordreset_email import AccountPasswordResetEmail
from portality.events.consumers.application_editor_group_assigned_notify import ApplicationEditorGroupAssignedNotify
from portality.events.consumers.application_publisher_accepted_notify import ApplicationPublisherAcceptedNotify
from portality.events.consumers.update_request_publisher_accepted_notify import UpdateRequestPublisherAcceptedNotify
from portality.events.consumers.application_publisher_assigned_notify import ApplicationPublisherAssignedNotify
from portality.events.consumers.update_request_publisher_assigned_notify import UpdateRequestPublisherAssignedNotify
from portality.events.consumers.journal_assed_assigned_notify import JournalAssedAssignedNotify
from portality.events.consumers.journal_editor_group_assigned_notify import JournalEditorGroupAssignedNotify


class EventsService(object):
    EVENT_CONSUMERS = [
        AccountCreatedEmail,
        AccountPasswordResetEmail,
        ApplicationAssedInprogressNotify,
        ApplicationAssedAssignedNotify,
        ApplicationEditorCompletedNotify,
        ApplicationEditorInProgressNotify,
        ApplicationEditorGroupAssignedNotify,
        ApplicationManedReadyNotify,
        ApplicationPublisherAcceptedNotify,
        ApplicationPublisherAssignedNotify,
        BGJobFinishedNotify,
        ApplicationPublisherCreatedNotify,
        ApplicationPublisherRevisionNotify,
        JournalAssedAssignedNotify,
        JournalEditorGroupAssignedNotify,
        UpdateRequestPublisherAcceptedNotify,
        UpdateRequestPublisherAssignedNotify
    ]

    def __init__(self):
        self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION"))

    def trigger(self, event):
        self.trigger_function(event)

    def consume(self, event):
        for consumer in self.EVENT_CONSUMERS:
            try:
                if consumer.consumes(event):
                    consumer.consume(event)
            except Exception as e:
                app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))
{'fraction_non_alphanumeric': 0.04550517104216388, 'fraction_numerical': 0.0, 'mean_word_length': 5.759139784946236, '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': '5373908', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1488, 'n_words': 250}