Test Failed
Push — master ( 9e4203...5a4935 )
by George
01:43
created

AbstractMessageTranslator.translate()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
1
import abc
2
import logging
3
4
logger = logging.getLogger(__name__)
5
6
7
class AbstractMessageTranslator(abc.ABC):
8
9
    @abc.abstractmethod
10
    def translate(self, message):
11
        '''Translates a given message to an appropriate format to message processing.
12
        This method should return a `dict` instance with two keys: `content`
13
        and `metadata`.
14
        The `content` should contain the translated message and, `metadata` a
15
        dictionary with translation metadata or an empty `dict`.
16
        '''
17
18
19
class StringMessageTranslator(AbstractMessageTranslator):
20
21
    def translate(self, message):
22
        logger.debug('{!r} will translate {!r}'.format(type(self).__name__, message))
23
        return {'content': str(message), 'metadata': {}}
24