Completed
Push — master ( cca123...0eea43 )
by George
02:25
created

IntMessageTranslator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A translate() 0 8 2
1
# -*- coding: utf-8 -*-
2
# vi:si:et:sw=4:sts=4:ts=4
3
4
import logging
5
6
logger = logging.getLogger(__name__)
7
8
9
class IntMessageTranslator(object):
10
11
    def translate(self, message):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
12
        logger.info('Translating: {}'.format(message))
13
        try:
14
            content = int(message)
15
        except ValueError:
16
            content = None
17
18
        return {'content': content}
19