# Path: ac_mediator/exceptions.py
# class ACFieldTranslateException(ACException):
#     pass
# 
# class ACException(Exception):
#     msg = None
#     status = None
# 
#     def __init__(self, msg=None, status=None):
# 
#         # Set defaults (if not set in subclass)
#         if self.msg is None:
#             self.msg = ""
#         if self.status is None:
#             self.msg = -1
# 
#         # Override with arguments (if any)
#         if msg is not None:
#             self.msg = msg
#         if status is not None:
#             self.status = status
# 
#     def __repr__(self):
#         return self.msg
# 
# class ACFilterParsingException(ACException):
#     pass
# 
# Path: services/acservice/utils.py
# def parse_filter(filter_string):
#     """
#     Parse a filter string using the 'filterExpr' grammar defined above.
#     This function returns a pyparsing.ParseResults object that should be further
#     processed with the build_filter_string method of a ACServiceTextSearchMixin instance.
#     """
#     return filterExpr.parseString(filter_string, parseAll=True)


from ac_mediator.exceptions import ACFieldTranslateException, ACException, ACFilterParsingException
from services.acservice.constants import *
from services.acservice.utils import parse_filter
import pyparsing
        with Audio Commons format. Therefore, the direct_fields_mapping dictionary would include
        an entry like 'AUDIO_COMMONS_TERM_FOR_FIELD_NAME': 'original_filename'.
        :return: dictionary mapping (keys are Audio Commons field names and values are services' resource field names)
        """
        return {}

    def translate_field(self, ac_field_name, result):
        """
        Given an audio commons field name and a dictionary representing a single result entry form a
        service response, return the corresponding field value compatible with the Audio
        Commons API. To perform this translation first we check if the field is available in
        self.direct_fields_mapping. If that is the case, this function simply returns the corresponding
        value according to the field name mapping specified in self.direct_fields_mapping.
        If field name is not available in self.direct_fields_mapping, then we check if it is available
        in the registry of translate field methods self.translate_field_methods_registry which is built
        when running self.conf_search() (see BaseACServiceSearchMixin.conf_search(self, *args).
        If a method for the ac_field_name exists in self.translate_field_methods_registry we call it and
        return its response.
        If field does not exist in self.direct_fields_mapping or self.translate_field_methods_registry
        we raise an exception to inform that field could not be translated.
        :param ac_field_name: name of the field in the Audio Commons API domain
        :param result: dictionary representing a single result entry form a service response
        :return: value of ac_field_name for the given result
        """
        try:
            if ac_field_name in self.direct_fields_mapping:
                return result[self.direct_fields_mapping[ac_field_name]]  # Do direct mapping
            if ac_field_name in self.translate_field_methods_registry:
                return self.translate_field_methods_registry[ac_field_name](result)  # Invoke translate method
        except Exception as e:  # Use generic catch on purpose so we can properly notify the frontend

# Path: ac_mediator/exceptions.py
# class ACFieldTranslateException(ACException):
#     pass
# 
# class ACException(Exception):
#     msg = None
#     status = None
# 
#     def __init__(self, msg=None, status=None):
# 
#         # Set defaults (if not set in subclass)
#         if self.msg is None:
#             self.msg = ""
#         if self.status is None:
#             self.msg = -1
# 
#         # Override with arguments (if any)
#         if msg is not None:
#             self.msg = msg
#         if status is not None:
#             self.status = status
# 
#     def __repr__(self):
#         return self.msg
# 
# class ACFilterParsingException(ACException):
#     pass
# 
# Path: services/acservice/utils.py
# def parse_filter(filter_string):
#     """
#     Parse a filter string using the 'filterExpr' grammar defined above.
#     This function returns a pyparsing.ParseResults object that should be further
#     processed with the build_filter_string method of a ACServiceTextSearchMixin instance.
#     """
#     return filterExpr.parseString(filter_string, parseAll=True)


# Path: services/acservice/search.py
from ac_mediator.exceptions import ACFieldTranslateException, ACException, ACFilterParsingException
from services.acservice.constants import *
from services.acservice.utils import parse_filter
import pyparsing

        with Audio Commons format. Therefore, the direct_fields_mapping dictionary would include
        an entry like 'AUDIO_COMMONS_TERM_FOR_FIELD_NAME': 'original_filename'.
        :return: dictionary mapping (keys are Audio Commons field names and values are services' resource field names)
        """
        return {}

    def translate_field(self, ac_field_name, result):
        """
        Given an audio commons field name and a dictionary representing a single result entry form a
        service response, return the corresponding field value compatible with the Audio
        Commons API. To perform this translation first we check if the field is available in
        self.direct_fields_mapping. If that is the case, this function simply returns the corresponding
        value according to the field name mapping specified in self.direct_fields_mapping.
        If field name is not available in self.direct_fields_mapping, then we check if it is available
        in the registry of translate field methods self.translate_field_methods_registry which is built
        when running self.conf_search() (see BaseACServiceSearchMixin.conf_search(self, *args).
        If a method for the ac_field_name exists in self.translate_field_methods_registry we call it and
        return its response.
        If field does not exist in self.direct_fields_mapping or self.translate_field_methods_registry
        we raise an exception to inform that field could not be translated.
        :param ac_field_name: name of the field in the Audio Commons API domain
        :param result: dictionary representing a single result entry form a service response
        :return: value of ac_field_name for the given result
        """
        try:
            if ac_field_name in self.direct_fields_mapping:
                return result[self.direct_fields_mapping[ac_field_name]]  # Do direct mapping
            if ac_field_name in self.translate_field_methods_registry:
                return self.translate_field_methods_registry[ac_field_name](result)  # Invoke translate method
        except Exception as e:  # Use generic catch on purpose so we can properly notify the frontend

            raise ACFieldTranslateException(