create filtering that prevents overwriting the device name

This commit is contained in:
Jakob Ketterl
2021-02-24 00:09:57 +01:00
parent 4199a583f8
commit f69d78926e
8 changed files with 99 additions and 25 deletions

23
owrx/property/filter.py Normal file
View File

@@ -0,0 +1,23 @@
from abc import ABC, abstractmethod
class Filter(ABC):
@abstractmethod
def apply(self, prop) -> bool:
pass
class ByPropertyName(Filter):
def __init__(self, *props):
self.props = props
def apply(self, prop) -> bool:
return prop in self.props
class ByLambda(Filter):
def __init__(self, func):
self.func = func
def apply(self, prop) -> bool:
return self.func(prop)