Passed
Push — master ( ba99c1...808282 )
by Markus
01:38
created

tcllib.devices.Device.__init__()   A

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nop 3
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3
"""Pseudo-devices for desktop/mobile requests"""
4
5
class Device():
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
best-practice introduced by
Too many instance attributes (12/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
6
    CLTP_STATES = {
7
        "MOBILE": 10,     # only show actual newer versions or HTTP 206
8
        "DESKTOP": 2010,  # always show latest version for FULL updates
9
    }
10
    MODE_STATES = {"OTA": 2, "FULL": 4}
11
    CHNL_STATES = {"3G": 1, "WIFI": 2}
12
    CKTP_STATES = {"AUTO": 1, "MANUAL": 2}
13
    CKOT_STATES = {"ALL": 1, "AOTA_ONLY": 2, "FOTA_ONLY": 3}
14
15
    def __init__(self, curef, fwver):
16
        self.curef = curef
17
        self.imei = ""
18
        self.osver = "7.1.1"
19
        self.fwver = fwver
20
        self.rtd = 0
21
        self.cltp = self.CLTP_STATES["DESKTOP"]
22
        self.mode = self.MODE_STATES["FULL"]
23
        self.type = "Firmware"
24
        self.chnl = self.CHNL_STATES["WIFI"]
25
        self.cktp = self.CKTP_STATES["MANUAL"]
26
        self.ckot = self.CKOT_STATES["ALL"]
27
        self.ua = "tcl"
28
29
    def is_rooted(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
30
        return (self.rtd == 1)
0 ignored issues
show
Unused Code Coding Style introduced by
There is an unnecessary parenthesis after return.
Loading history...
31
32
    def set_rooted(self, new_state: bool):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
33
        if new_state:
34
            self.rtd = 1
35
        else:
36
            self.rtd = 0
37
38
    def set_cltp(self, new_cltp: str):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
39
        # (Numerical CLTPs can be set by direct assigns.)
40
        # Throws exception when invalid cltp given:
41
        self.cltp = self.CLTP_STATES[new_cltp]
42
43
    def set_mode(self, new_mode: str):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
44
        # (Numerical MODEs can be set by direct assigns.)
45
        # Throws exception when invalid mode given:
46
        self.mode = self.MODE_STATES[new_mode]
47
48
    def set_chnl(self, new_chnl: str):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
49
        # (Numerical CHNLs can be set by direct assigns.)
50
        # Throws exception when invalid mode given:
51
        self.chnl = self.CHNL_STATES[new_chnl]
52
53
    def set_ckot(self, new_ckot: str):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
54
        # (Numerical CKOTs can be set by direct assigns.)
55
        # Throws exception when invalid mode given:
56
        self.ckot = self.CKOT_STATES[new_ckot]
57
58
class MobileDevice(Device):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
59
    def __init__(self, curef="PRD-63117-011", fwver="AAO472"):
60
        super().__init__(curef, fwver)
61
        self.imei = "3531510"
62
        self.set_cltp("MOBILE")
63
        self.set_mode("OTA")
64
        self.ua = "com.tcl.fota/5.1.0.2.0029.0, Android"
65
66
class DesktopDevice(Device):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
67
    def __init__(self, curef="PRD-63117-011", fwver="AAA000"):
68
        super().__init__(curef, fwver)
69
        self.imei = "543212345000000"
70
        self.set_cltp("DESKTOP")
71
        self.set_mode("FULL")
72