response formatter selects map fn or fn by type of message
This commit is contained in:
parent
ed7c3fabc2
commit
d52ac8fd74
@ -1,9 +1,13 @@
|
||||
import abc
|
||||
|
||||
from funcy import identity
|
||||
|
||||
from pyinfra.utils.func import lift
|
||||
|
||||
|
||||
class ResponseFormatter(abc.ABC):
|
||||
def __call__(self, message):
|
||||
return map(self.format, message)
|
||||
return (identity if isinstance(message, dict) else lift)(self.format)(message)
|
||||
|
||||
@abc.abstractmethod
|
||||
def format(self, message):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user