Test Setup Failed
Push — develop ( d0ed0b...b83390 )
by Dean
02:18
created

PersonalLists.run()   A

Complexity

Conditions 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12
Metric Value
cc 3
dl 0
loc 18
ccs 0
cts 9
cp 0
crap 12
rs 9.4285
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
class PersonalLists(Lists):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
This class has no __init__ method.
Loading history...
11 1
    data = [SyncData.Personal]
12
    mode = SyncMode.Pull
13 1
14
    @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
    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 1
            return None
38
39
        # Create playlist
40
        return super(PersonalLists, self).create_playlist(uri, name)
41