<commit_before>import datetime
import json

from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ungettext

from couchexport.models import SavedExportSchema

from corehq import privileges
from corehq.apps.accounting.utils import (
    get_active_reminders_by_domain_name,
    log_accounting_error,
)
from corehq.apps.app_manager.dbaccessors import get_all_apps
from corehq.apps.cloudcare.dbaccessors import get_cloudcare_apps
from corehq.apps.data_interfaces.models import AutomaticUpdateRule
from corehq.apps.domain.models import Domain
from corehq.apps.fixtures.models import FixtureDataType
from corehq.apps.reminders.models import METHOD_SMS_SURVEY, METHOD_IVR_SURVEY
from corehq.apps.users.models import CommCareUser, UserRole
from corehq.const import USER_DATE_FORMAT


class BaseModifySubscriptionHandler(object):
    def __init__(self, domain, new_plan_version, changed_privs, date_start=None):
        self.domain = domain if isinstance(domain, Domain) else Domain.get_by_name(domain)
        self.date_start = date_start or datetime.date.today()
        self.new_plan_version = new_plan_version

        self.privileges = filter(lambda x: x in self.supported_privileges, changed_privs)

    def get_response(self):
        response = []
        for priv in self.privileges:
            message = self.privilege_to_response_function()[priv](self.domain)
            if message is not None:
                response.append(message)
        return response
<commit_msg>reimplement get_response<commit_after>import datetime
import json

from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ungettext

from couchexport.models import SavedExportSchema

from corehq import privileges
from corehq.apps.accounting.utils import (
    get_active_reminders_by_domain_name,
    log_accounting_error,
)
from corehq.apps.app_manager.dbaccessors import get_all_apps
from corehq.apps.cloudcare.dbaccessors import get_cloudcare_apps
from corehq.apps.data_interfaces.models import AutomaticUpdateRule
from corehq.apps.domain.models import Domain
from corehq.apps.fixtures.models import FixtureDataType
from corehq.apps.reminders.models import METHOD_SMS_SURVEY, METHOD_IVR_SURVEY
from corehq.apps.users.models import CommCareUser, UserRole
from corehq.const import USER_DATE_FORMAT


class BaseModifySubscriptionHandler(object):
    def __init__(self, domain, new_plan_version, changed_privs, date_start=None):
        self.domain = domain if isinstance(domain, Domain) else Domain.get_by_name(domain)
        self.date_start = date_start or datetime.date.today()
        self.new_plan_version = new_plan_version

        self.privileges = filter(lambda x: x in self.supported_privileges, changed_privs)

    def get_response(self):
        return filter(
            lambda message: message is not None,
            map(
                lambda privilege: self.privilege_to_response_function()[privilege](self.domain),
                self.privileges
            )
        )

{'fraction_non_alphanumeric': 0.06115335868187579, 'fraction_numerical': 0.0, 'mean_word_length': 4.405821917808219, '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': '3512220', 'n_tokens_mistral': 971, 'n_tokens_neox': 944, 'n_words': 219}