NearEvent   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 8
c 1
b 1
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B map() 0 9 7
1
from intelligine.core.exceptions import NearNothingFound
2
from intelligine.synergy.event.Event import Event
3
from synergine_xyz.mechanism.AroundMechanism import AroundMechanism
4
5
6
class NearEvent(Event):
7
8
    _mechanism = AroundMechanism
9
    _near_name = None
10
    _near_map = lambda self, near_object_id, context: False
11
12
    # TODO: parameters en entre/sortie c pas bon ca
13
    def map(self, context, parameters, stop_at_first=False, filter=lambda near_object_id, context: True):
14
        parameters[self._near_name] = []
15
        for near_object_id in parameters['objects_ids_near']:
16
            if self._near_map(near_object_id, context) and filter(near_object_id, context):
17
                parameters[self._near_name].append(near_object_id)
18
                if stop_at_first:
19
                    return
20
        if not parameters[self._near_name]:
21
            raise NearNothingFound()
22