GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bc5271...0254c9 )
by Michael
01:27
created

with_logger()   A

Complexity

Conditions 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 8
rs 9.4285
1
import logging
2
import time
3
from functools import wraps
4
5
_logger = logging.getLogger(__name__)
6
7
8
def with_logger(cls):
9
    attr_name = '_logger'
10
    cls_name = cls.__qualname__
11
    module = cls.__module__
12
    assert module is not None
13
    cls_name = module + '.' + cls_name
14
    setattr(cls, attr_name, logging.getLogger(cls_name))
15
    return cls
16
17
18
def _timed_decorator(f, logger=_logger, limit=0.2):
19
    @wraps(f)
20
    def wrapper(*args, **kwargs):
21
        start = time.time()
22
        result = f(*args, **kwargs)
23
        elapsed = (time.time() - start)
24
        if elapsed >= limit:
25
            logger.info("%s took %s s to finish" % (f.__name__, str(elapsed)))
26
        return result
27
    return wrapper
28
29
30
def timed(*args, **kwargs):
31
    if len(args) == 1 and callable(args[0]):
32
        return _timed_decorator(args[0])
33
    else:
34
        return lambda f: _timed_decorator(f, *args, **kwargs)
35