def calc_sum(app, need, needs, option, filter=None, links_only=False):
if not links_only:<EOL><INDENT>check_needs = needs.values()<EOL><DEDENT>else:<EOL><INDENT>check_needs = []<EOL>for link in need["<STR_LIT>"]:<EOL><INDENT>check_needs.append(needs[link])<EOL><DEDENT><DEDENT>calculated_sum = <NUM_LIT:0><EOL>for check_need in check_needs:<EOL><INDENT>if filter is not None:<EOL><INDENT>try:<EOL><INDENT>if not filter_single_need(check_need, filter):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except ValueError as e:<EOL><INDENT>pass<EOL><DEDENT>except NeedInvalidFilter as ex:<EOL><INDENT>logger.warning('<STR_LIT>'.format(ex))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>calculated_sum += float(check_need[option])<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return calculated_sum<EOL>
Sums the values of a given option in filtered needs up to single number.

Useful e.g. for calculating the amount of needed hours for implementation of all linked
specification needs.


**Input data**

.. spec:: Do this
   :id: sum_input_1
   :hours: 7
   :collapse: False

.. spec:: Do that
   :id: sum_input_2
   :hours: 15
   :collapse: False

.. spec:: Do too much
   :id: sum_input_3
   :hours: 110
   :collapse: False

**Example 2**

.. code-block:: jinja

   .. req:: Result 1
      :amount: [[calc_sum("hours")]]

.. req:: Result 1
   :amount: [[calc_sum("hours")]]
   :collapse: False


**Example 2**

.. code-block:: jinja

   .. req:: Result 2
      :amount: [[calc_sum("hours", "hours.isdigit() and float(hours) > 10")]]

.. req:: Result 2
   :amount: [[calc_sum("hours", "hours.isdigit() and float(hours) > 10")]]
   :collapse: False

**Example 3**

.. code-block:: jinja

   .. req:: Result 3
      :links: sum_input_1; sum_input_3
      :amount: [[calc_sum("hours", links_only="True")]]

.. req:: Result 3
   :links: sum_input_1; sum_input_3
   :amount: [[calc_sum("hours", links_only="True")]]
   :collapse: False

**Example 4**

.. code-block:: jinja

   .. req:: Result 4
      :links: sum_input_1; sum_input_3
      :amount: [[calc_sum("hours", "hours.isdigit() and float(hours) > 10", "True")]]

.. req:: Result 4
   :links: sum_input_1; sum_input_3
   :amount: [[calc_sum("hours", "hours.isdigit() and float(hours) > 10", "True")]]
   :collapse: False

:param option: Options, from which the numbers shall be taken
:param filter: Filter string, which all needs must passed to get their value added.
:param links_only: If "True", only linked needs are taken into account.

:return: A float number