Passed
Push — master ( 64ad20...04166b )
by Dean
02:49
created

Identifier.get_ids()   B

Complexity

Conditions 5

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5
Metric Value
cc 5
dl 0
loc 20
ccs 14
cts 14
cp 1
crap 5
rs 8.5454
1 1
from plugin.core.constants import GUID_SERVICES
2
3 1
from plex_metadata import Guid
4 1
import logging
5
6
7 1
log = logging.getLogger(__name__)
8
9
10 1
class Identifier(object):
11 1
    @classmethod
12 1
    def get_ids(cls, guid, strict=True):
13 1
        ids = {}
14
15 1
        if not guid:
16 1
            return ids
17
18 1
        if type(guid) is str:
19
            # Parse raw guid
20 1
            guid = Guid.parse(guid)
21
22 1
        if guid.service in GUID_SERVICES:
23 1
            ids[guid.service] = guid.id
24 1
        elif not strict:
25 1
            log.info('Unknown identifier service: "%s"', guid.service)
26
        else:
27 1
            log.info('Unknown identifier service: "%s" [strict]', guid.service)
28 1
            return None
29
30
        return ids
31