create filtering that prevents overwriting the device name
This commit is contained in:
23
owrx/property/filter.py
Normal file
23
owrx/property/filter.py
Normal 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)
|
||||
Reference in New Issue
Block a user