<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_linked_values(app, need, needs, result, search_option, search_value, filter_string=None, one_hit=False):
 """ Returns a specific value, if for all linked needs a given option has a given value. The linked needs can be filtered by using the ``filter`` option. If ``one_hit`` is set to True, only one linked need must have a positive match for the searched value. **Examples** **Needs used as input data** .. code-block:: jinja .. req:: Input A :id: clv_A :status: in progress .. req:: Input B :id: clv_B :status: in progress .. spec:: Input C :id: clv_C :status: closed .. req:: Input A :id: clv_A :status: in progress :collapse: False .. req:: Input B :id: clv_B :status: in progress :collapse: False .. spec:: Input C :id: clv_C :status: closed :collapse: False **Example 1: Positive check** Status gets set to *progress*. .. code-block:: jinja .. spec:: result 1: Positive check :links: clv_A, clv_B :status: [[check_linked_values('progress', 'status', 'in progress' )]] .. spec:: result 1: Positive check :id: clv_1 :links: clv_A, clv_B :status: [[check_linked_values('progress', 'status', 'in progress' )]] :collapse: False **Example 2: Negative check** Status gets not set to *progress*, because status of linked need *clv_C* does not match *"in progress"*. .. code-block:: jinja .. spec:: result 2: Negative check :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress' )]] .. spec:: result 2: Negative check :id: clv_2 :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress' )]] :collapse: False **Example 3: Positive check thanks of used filter** status gets set to *progress*, because linked need *clv_C* is not part of the filter. .. code-block:: jinja .. spec:: result 3: Positive check thanks of used filter :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', 'type == "req" ' )]] .. spec:: result 3: Positive check thanks of used filter :id: clv_3 :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', 'type == "req" ' )]] :collapse: False **Example 4: Positive check thanks of one_hit option** Even *clv_C* has not the searched status, status gets anyway set to *progress*. That's because ``one_hit`` is used so that only one linked need must have the searched value. .. code-block:: jinja .. spec:: result 4: Positive check thanks of one_hit option :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', one_hit=True )]] .. spec:: result 4: Positive check thanks of one_hit option :id: clv_4 :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', one_hit=True )]] :collapse: False **Result 5: Two checks and a joint status** Two checks are performed and both are positive. So their results get joined. .. code-block:: jinja .. spec:: result 5: Two checks and a joint status :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', one_hit=True )]] [[check_linked_values('closed', 'status', 'closed', one_hit=True )]] .. spec:: result 5: Two checks and a joint status :id: clv_5 :links: clv_A, clv_B, clv_C :status: [[check_linked_values('progress', 'status', 'in progress', one_hit=True )]] [[check_linked_values('closed', 'status', 'closed', one_hit=True )]] :collapse: False :param result: value, which gets returned if all linked needs have parsed the checks :param search_option: option name, which is used n linked needs for the search :param search_value: value, which an option of a linked need must match :param filter_string: Checks are only performed on linked needs, which pass the defined filter :param one_hit: If True, only one linked need must have a positive check :return: result, if all checks are positive """

    links = need["links"]
    if not isinstance(search_value, list):
        search_value = [search_value]

    for link in links:
        if filter_string is not None:
            try:
                if not filter_single_need(needs[link], filter_string):
                    continue
            except Exception as e:
                logger.warning("CheckLinkedValues: Filter {0} not valid: Error: {1}".format(filter_string, e))

        if not one_hit and not needs[link][search_option] in search_value:
            return None
        elif one_hit and needs[link][search_option] in search_value:
            return result

    return result