Passed
Push — beta ( 8befa3...d680d6 )
by Dean
06:01 queued 03:09
created

format_unsupported()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 3.6875

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 1
cts 4
cp 0.25
rs 9.4285
cc 2
crap 3.6875
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
IGNORED_SERVICES = [
5
    'none',
6
    'plex'
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 is None or service in IGNORED_SERVICES:
29
            logger.info('Ignoring service: %s' % service)
30
            continue
31
32
        # Log unsupported service warning
33
        logger.warn('Unsupported service: %s' % service, extra={
34
            'event': {
35
                'module': __name__,
36
                'name': 'unsupported_service',
37
                'key': service
38
            }
39
        })
40