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

AbstractMessageTranslator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A translate() 0 8 1
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