Completed
Push — master ( 8beaf7...b11f53 )
by Oleksandr
01:20
created

isotopic_logging.SimplePrefixInjector   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isotopic_logging.StaticPrefixInjector.__init__() 0 3 1
1
# -*- coding: utf-8 -*-
2
3 1
from .generators import generate_oid
4 1
from .prefix import make_prefix, join_prefix
5
6
7 1
class DirectPrefixInjector(object):
8
9 1
    __slots__ = ['prefix', ]
10
11 1
    def __init__(self, prefix):
12 1
        self.prefix = prefix
13
14 1
    def mark(self, message):
15 1
        return self.prefix + message
16
17
18 1
class StaticPrefixInjector(DirectPrefixInjector):
19
20 1
    def __init__(self, prefix, delimiter=None):
21 1
        prefix = make_prefix(prefix, delimiter)
22 1
        super(StaticPrefixInjector, self).__init__(prefix)
23
24
25 1
class AutoprefixInjector(StaticPrefixInjector):
26
27 1
    def __init__(self, oid_generator=None, delimiter=None):
28 1
        autopart = generate_oid(oid_generator)
29 1
        super(AutoprefixInjector, self).__init__(autopart, delimiter)
30
31
32 1
class HybrydPrefixInjector(DirectPrefixInjector):
33
34 1
    def __init__(self, prefix, oid_generator=None, delimiter=None):
35 1
        autopart = generate_oid(oid_generator)
36 1
        prefix = join_prefix([autopart, prefix, ], delimiter)
37 1
        super(HybrydPrefixInjector, self).__init__(prefix)
38
39
40 1
def merge_injectors(*args):
41 1
    prefix = ''.join([x.prefix for x in args])
42
    return DirectPrefixInjector(prefix)
43