<commit_before>import re
from werkzeug.datastructures import MultiDict
from ..helpers.questions import QuestionsLoader


class SearchFilters(object):
    """Provides access to the filters for a search based on request parameters
    """

    @staticmethod
    def get_current_lot(request):
        current_lot = request.args.get('lot', None)
        if current_lot is not None:
            return current_lot
        else:
            return False

    @staticmethod
    def get_filters_from_default_question(question):
        # boolean questions have no options as 'Yes' or 'No' is
        # implied
        return {
            'label': question['question'],
            'name': question['id'],
            'id': question['id'],
            'value': 'true',
            'lots': [lot.strip() for lot in (
                question['dependsOnLots'].lower().split(",")
            )]
        }

    @staticmethod
    def get_filters_from_question_with_options(question, index):
        filter_group = []

        if re.match('^serviceTypes(SCS|SaaS|IaaS)', question['id']):
            filter_name = 'serviceTypes'
        else:
            filter_name = question['id']
        for option in question['options']:
            filter_id = option['label'].lower().replace(' ', '-')
            filter = {
                'label': option['label'],
                'name': filter_name,
                'id': '%s-%s' % (filter_name, filter_id),
                'value': option['label'].lower(),
                'lots': [lot.strip() for lot in (
                    question['dependsOnLots'].lower().split(",")
                )]
            }
            filter_group.append(filter)
            index = index + 1
        return filter_group

    @staticmethod
    def get_filter_groups_from_questions(manifest=None, questions_dir=None):
        filter_groups = []
        g6_questions = QuestionsLoader(
            manifest=manifest,
            questions_dir=questions_dir
        )

        def add_filters_for_question(question=None, filters=None):
            questions_with_options = [
                'radios',
                'checkboxes'
            ]
            # if the 1st question has options, they will become the
            # filters and it's details will define the group
            if question['type'] in questions_with_options:
                filters = (
                    filters +
                    SearchFilters.get_filters_from_question_with_options(
                        question,
                        len(filters)
                    )<commit_msg>Make explicit which arguments are required<commit_after>import re
from werkzeug.datastructures import MultiDict
from ..helpers.questions import QuestionsLoader


class SearchFilters(object):
    """Provides access to the filters for a search based on request parameters
    """

    @staticmethod
    def get_current_lot(request):
        current_lot = request.args.get('lot', None)
        if current_lot is not None:
            return current_lot
        else:
            return False

    @staticmethod
    def get_filters_from_default_question(question):
        # boolean questions have no options as 'Yes' or 'No' is
        # implied
        return {
            'label': question['question'],
            'name': question['id'],
            'id': question['id'],
            'value': 'true',
            'lots': [lot.strip() for lot in (
                question['dependsOnLots'].lower().split(",")
            )]
        }

    @staticmethod
    def get_filters_from_question_with_options(question, index):
        filter_group = []

        if re.match('^serviceTypes(SCS|SaaS|IaaS)', question['id']):
            filter_name = 'serviceTypes'
        else:
            filter_name = question['id']
        for option in question['options']:
            filter_id = option['label'].lower().replace(' ', '-')
            filter = {
                'label': option['label'],
                'name': filter_name,
                'id': '%s-%s' % (filter_name, filter_id),
                'value': option['label'].lower(),
                'lots': [lot.strip() for lot in (
                    question['dependsOnLots'].lower().split(",")
                )]
            }
            filter_group.append(filter)
            index = index + 1
        return filter_group

    @staticmethod
    def get_filter_groups_from_questions(manifest, questions_dir):
        filter_groups = []
        g6_questions = QuestionsLoader(
            manifest=manifest,
            questions_dir=questions_dir
        )

        def add_filters_for_question(question, filters):
            questions_with_options = [
                'radios',
                'checkboxes'
            ]
            # if the 1st question has options, they will become the
            # filters and it's details will define the group
            if question['type'] in questions_with_options:
                filters = (
                    filters +
                    SearchFilters.get_filters_from_question_with_options(
                        question,
                        len(filters)
                    )
{'fraction_non_alphanumeric': 0.10183930300096805, 'fraction_numerical': 0.0011616650532429815, 'mean_word_length': 1.7507987220447285, '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': '5918461', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1284, 'n_words': 311}