| Total Complexity | 10 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # |
||
| 2 | # Copyright 2001 - 2020 Ludek Smid [http://www.ospace.net/] |
||
| 3 | # |
||
| 4 | # This file is part of Outer Space. |
||
| 5 | # |
||
| 6 | # Outer Space is free software; you can redistribute it and/or modify |
||
| 7 | # it under the terms of the GNU General Public License as published by |
||
| 8 | # the Free Software Foundation; either version 2 of the License, or |
||
| 9 | # (at your option) any later version. |
||
| 10 | # |
||
| 11 | # Outer Space is distributed in the hope that it will be useful, |
||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 14 | # GNU General Public License for more details. |
||
| 15 | # |
||
| 16 | # You should have received a copy of the GNU General Public License |
||
| 17 | # along with Outer Space; if not, write to the Free Software |
||
| 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||
| 19 | # |
||
| 20 | |||
| 21 | |||
| 22 | def false(value): |
||
| 23 | return False |
||
| 24 | |||
| 25 | |||
| 26 | def true(value): |
||
| 27 | return True |
||
| 28 | |||
| 29 | |||
| 30 | class Filter(object): |
||
| 31 | def __init__(self): |
||
| 32 | self.functions = [] |
||
| 33 | |||
| 34 | def add(self, func): |
||
| 35 | self.functions.append(func) |
||
| 36 | |||
| 37 | def OR(self, value): |
||
| 38 | for func in self.functions: |
||
| 39 | if func(value): |
||
| 40 | return True |
||
| 41 | return False |
||
| 42 | |||
| 43 | def AND(self, value): |
||
| 44 | for func in self.functions: |
||
| 45 | if not func(value): |
||
| 46 | return False |
||
| 47 | return True |
||
| 48 |