| Total Complexity | 8 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | from intelligine.core.exceptions import NearNothingFound |
||
| 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 |