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
|
import abc
|
||||||
|
|
||||||
|
from funcy import identity
|
||||||
|
|
||||||
|
from pyinfra.utils.func import lift
|
||||||
|
|
||||||
|
|
||||||
class ResponseFormatter(abc.ABC):
|
class ResponseFormatter(abc.ABC):
|
||||||
def __call__(self, message):
|
def __call__(self, message):
|
||||||
return map(self.format, message)
|
return (identity if isinstance(message, dict) else lift)(self.format)(message)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def format(self, message):
|
def format(self, message):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user