Passed
Push — master ( aeb165...d9ae97 )
by Dean
03:04
created

PersonalLists.run()   A

Complexity

Conditions 3

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 1
CRAP Score 9.3211
Metric Value
dl 18
loc 18
ccs 1
cts 9
cp 0.1111
rs 9.4285
cc 3
crap 9.3211
1 1
from plugin.sync.core.enums import SyncData, SyncMode, SyncMedia
2 1
from plugin.sync.modes.pull.lists.base import Lists
3
4 1
import elapsed
5 1
import logging
6
7 1
log = logging.getLogger(__name__)
8
9
10 1 View Code Duplication
class PersonalLists(Lists):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11 1
    data = [SyncData.Personal]
12 1
    mode = SyncMode.Pull
13
14 1
    @elapsed.clock
15
    def run(self):
16
        # Retrieve plex sections
17
        p_sections, p_sections_map = self.sections()
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named sections.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Unused Code introduced by
The variable p_sections seems to be unused.
Loading history...
18
19
        # Retrieve plex playlists
20
        p_playlists = dict(self.get_playlists())
21
22
        # Retrieve trakt lists
23
        t_lists = self.trakt[(SyncMedia.Lists, SyncData.Personal)]
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named trakt.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
24
25
        if t_lists is None:
26
            log.warn('Unable to retrieve liked lists')
27
            return
28
29
        # Process trakt lists
30
        for _, t_list in t_lists.items():
31
            self.process(SyncData.Personal, p_playlists, p_sections_map, t_list)
32
33 1
    def create_playlist(self, uri, name):
34
        # Check if playlist creation is enabled
35
        if self.configuration['sync.lists.personal.playlists'] is False:
0 ignored issues
show
Bug introduced by
The Instance of PersonalLists does not seem to have a member named configuration.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
36
            log.info('No playlist found named %r ("Create playlists in plex" not enabled)', name)
37
            return None
38
39
        # Create playlist
40
        return super(PersonalLists, self).create_playlist(uri, name)
41