Passed
Pull Request — master (#35)
by
unknown
07:19
created

PyDMXControl.profiles.Showtec._Compact_PAR   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 77
Duplicated Lines 72.73 %

Importance

Changes 0
Metric Value
wmc 3
eloc 46
dl 56
loc 77
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Compact_PAR_7_Q4_4Ch.__init__() 15 15 1
A Compact_PAR_7_Q4_6Ch.__init__() 18 18 1
A Compact_PAR_7_Q4_11Ch.__init__() 23 23 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
"""
2
 *  PyDMXControl: A Python 3 module to control DMX using uDMX.
3
 *                Featuring fixture profiles, built-in effects and a web control panel.
4
 *  <https://github.com/MattIPv4/PyDMXControl/>
5
 *  Copyright (C) 2018 Matt Cowley (MattIPv4) ([email protected])
6
"""
7
8
from ..defaults import Fixture, Vdim
9
10
11
class Compact_PAR_7_Q4_4Ch(Vdim):
12
13 View Code Duplication
    def __init__(self, *args, **kwargs):
14
        """
15
        These models can be configured to use 4, 6, or 11 DMX channels. Use this
16
        class for the 4 channel configuration.
17
        """
18
        super().__init__(*args, **kwargs)
19
20
        self._register_channel('red', vdim=True)
21
        self._register_channel_aliases('red', 'r')
22
        self._register_channel('green', vdim=True)
23
        self._register_channel_aliases('green', 'g')
24
        self._register_channel('blue', vdim=True)
25
        self._register_channel_aliases('blue', 'b')
26
        self._register_channel('white', vdim=True)
27
        self._register_channel_aliases('white', 'w')
28
29
30
class Compact_PAR_7_Q4_6Ch(Fixture):
31
32 View Code Duplication
    def __init__(self, *args, **kwargs):
33
        """
34
        These models can be configured to use 4, 6, or 11 DMX channels. Use this
35
        class for the 6 channel configuration.
36
        """
37
        super().__init__(*args, **kwargs)
38
39
        self._register_channel('dimmer')
40
        self._register_channel_aliases('dimmer', 'dim', 'd')
41
        self._register_channel('strobe')
42
        self._register_channel('red')
43
        self._register_channel_aliases('red', 'r')
44
        self._register_channel('green')
45
        self._register_channel_aliases('green', 'g')
46
        self._register_channel('blue')
47
        self._register_channel_aliases('blue', 'b')
48
        self._register_channel('white')
49
        self._register_channel_aliases('white', 'w')
50
51
52
class Compact_PAR_7_Q4_11Ch(Fixture):
53
54 View Code Duplication
    def __init__(self, *args, **kwargs):
55
        """
56
        These models can be configured to use 4, 6, or 11 DMX channels. Use this
57
        class for the 11 channel configuration.
58
        """
59
        super().__init__(*args, **kwargs)
60
61
        self._register_channel('dimmer')
62
        self._register_channel_aliases('dimmer', 'dim', 'd')
63
        self._register_channel('strobe')
64
        self._register_channel('random strobe')
65
        self._register_channel('color presets')
66
        self._register_channel('color running')
67
        self._register_channel('color running speed')
68
        self._register_channel('sound mode')
69
        self._register_channel('red')
70
        self._register_channel_aliases('red', 'r')
71
        self._register_channel('green')
72
        self._register_channel_aliases('green', 'g')
73
        self._register_channel('blue')
74
        self._register_channel_aliases('blue', 'b')
75
        self._register_channel('white')
76
        self._register_channel_aliases('white', 'w')
77