osm_poi_matchmaker.utils.timing   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Timing.end() 0 4 1
A Timing.__init__() 0 2 1
A Timing.__seconds_to_str() 0 4 2
1
# -*- coding: cp1250 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
try:
4
    import logging
5
    import sys
6
    import datetime
7
    import time
8
except ImportError as err:
9
    logging.error('Error %s import module: %s', __name__, err)
10
    logging.exception('Exception occurred')
11
12
    sys.exit(128)
13
14
__author__ = 'kszalai'
15
16
17
class Timing:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
18
    def __init__(self):
19
        self.start = time.time()
20
21
    def end(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
22
        elapsed = time.time() - self.start
23
        # return self.__seconds_to_str(elapsed)
24
        return str(datetime.timedelta(seconds=elapsed))
25
26
    def __seconds_to_str(self, t):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "t" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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...
27
        return "%d:%02d:%02d.%03d" % \
28
               reduce(lambda ll, b: divmod(ll[0], b) + ll[1:],
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable reduce does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'reduce'
Loading history...
29
                      [(t * 1000,), 1000, 60, 60])
30