Passed
Push — master ( ce647f...f4ead8 )
by Dean
02:57
created

log_unsupported()   A

Complexity

Conditions 4

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 15.664

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
ccs 1
cts 10
cp 0.1
rs 9.2
cc 4
crap 15.664
1 1
from plugin.sync.modes.core.base.mode import Mode
2 1
from plugin.sync.modes.core.base.pull import PullListsMode
3
4 1
unsupported_services = {
5
    'none': True,
6
    'plex': True
7
}
8
9
10 1
def mark_unsupported(dictionary, rating_key, guid):
11
    service = guid.service if guid else None
12
13
    if service not in dictionary:
14
        dictionary[service] = []
15
16
    dictionary[service].append(rating_key)
17
18
19 1
def log_unsupported(logger, message, dictionary):
20
    if len(dictionary) < 1:
21
        return
22
23
    # Display unsupported service list
24
    logger.info(message, len(dictionary))
25
26
    # Display individual warnings for each service
27
    for service in dictionary.keys():
28
        if service not in unsupported_services:
29
            # First occurrence of unsupported service
30
            logger.warn('Unsupported service: %s' % service)
31
32
            # Mark unsupported service as "seen"
33
            unsupported_services[service] = True
34
            continue
35
36
        # Duplicate occurrence of unsupported service
37
        logger.warn('Unsupported service: %s' % service, extra={
38
            'duplicate': True
39
        })
40