Completed
Push — develop ( e4f288...dec8f0 )
by Jace
02:13
created

yorm.load_file()   B

Complexity

Conditions 6

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6.1979
Metric Value
cc 6
dl 0
loc 29
rs 7.5384
ccs 14
cts 17
cp 0.8235
crap 6.1979
1
"""Shared internal classes and functions."""
2
3 1
import collections
4 1
import logging
5
6
7
# CONSTANTS ####################################################################
8
9
10 1
PRINT_VERBOSITY = 0  # minimum verbosity to using `print`
11 1
STR_VERBOSITY = 3  # minimum verbosity to use verbose `__str__`
12 1
MAX_VERBOSITY = 4  # maximum verbosity level implemented
13
14 1
OVERRIDE_MESSAGE = "Method must be implemented in subclasses"
15
16
17
# GLOBALS ######################################################################
18
19
20 1
verbosity = 0  # global verbosity setting for controlling string formatting
21
22 1
attrs = collections.defaultdict(dict)
23
24
25
# LOGGING ######################################################################
26
27
28
def _trace(self, message, *args, **kwargs):  # pragma: no cover (manual test)
29
    """Handler for a new TRACE logging level."""
30
    if self.isEnabledFor(logging.DEBUG - 1):
31
        self._log(logging.DEBUG - 1, message, args, **kwargs)  # pylint: disable=protected-access
32
33
34 1
logging.addLevelName(logging.DEBUG - 1, "TRACE")
35 1
logging.Logger.trace = _trace
36
37 1
logger = logging.getLogger
38 1
log = logger(__name__)
39
40
41
# DECORATORS ###################################################################
42
43
44 1
class classproperty(object):
45
    """Read-only class property decorator."""
46
47 1
    def __init__(self, getter):
48 1
        self.getter = getter
49
50 1
    def __get__(self, instance, owner):
51
        return self.getter(owner)
52