Passed
Push — master ( 596b4f...1a320d )
by Vinicius
04:17 queued 14s
created

kytos.core   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 45
ccs 18
cts 19
cp 0.9474
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A log() 0 5 1
A extend_descriptors() 0 12 2
1
"""Kytos.core is the module with main classes used in Kytos."""
2 1
import sys
3
4 1
from kytos.core.auth import authenticated
5 1
from kytos.core.controller import Controller
6 1
from kytos.core.events import KytosEvent
7 1
from kytos.core.logs import get_napp_logger
8 1
from kytos.core.napps import KytosNApp, rest
9
10 1
from .metadata import __version__
11
12 1
__all__ = (
13
    "authenticated",
14
    "Controller",
15
    "KytosEvent",
16
    "KytosNApp",
17
    "log",
18
    "rest",
19
    "__version__",
20
)
21
22
23 1
def extend_descriptors(inst, **kwargs):
24
    """Creates wrapper of instance with descriptors"""
25
26 1
    class MFacade:
27
        """Wrapper class for provided instance"""
28
29 1
        def __getattr__(self, name):
30 1
            return getattr(inst, name)
31
32 1
    for (key, value) in kwargs.items():
33 1
        setattr(MFacade, key, value)
34 1
    return MFacade()
35
36
37 1
@property
38 1
def log(self):
39
    """Get appropriate napp logger at module import time,
40
    rather than module initialization time"""
41
    return self.get_napp_logger()
42
43
44
sys.modules[__name__] = extend_descriptors(sys.modules[__name__], log=log)
45