Passed
Push — master ( 2adcb6...75d235 )
by Markus
01:50
created

EncryptHeaderResult.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module 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...
2
3
import xml.dom.minidom
4
5
from defusedxml import ElementTree
6
7
from .. import dumpmgr
8
9
10
class TclResult:
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...
11
    def __init__(self, xml: str):
0 ignored issues
show
Comprehensibility Bug introduced by
xml is re-defining a name which is already available in the outer-scope (previously defined on line 3).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
12
        self.raw_xml = xml
13
        self.dumper = dumpmgr.DumpMgr()
14
        self.dumper.write_dump(xml)
15
16
    def delete_dump(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...
17
        self.dumper.delete_last_dump()
18
19
    def pretty_xml(self):
20
        """Return prettified input XML with ``xml.dom.minidom``."""
21
        mdx = xml.dom.minidom.parseString(self.raw_xml)
22
        return mdx.toprettyxml(indent="  ")
23
24
class CheckResult(TclResult):
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 (8/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
25
    def __init__(self, xml: str):
0 ignored issues
show
Comprehensibility Bug introduced by
xml is re-defining a name which is already available in the outer-scope (previously defined on line 3).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
26
        super().__init__(xml)
27
        root = ElementTree.fromstring(xml)
28
        self.curef = root.find("CUREF").text
29
        self.fvver = root.find("VERSION").find("FV").text
30
        self.tvver = root.find("VERSION").find("TV").text
31
        self.fw_id = root.find("FIRMWARE").find("FW_ID").text
32
        fileinfo = root.find("FIRMWARE").find("FILESET").find("FILE")
33
        self.fileid = fileinfo.find("FILE_ID").text
34
        self.filename = fileinfo.find("FILENAME").text
35
        self.filesize = fileinfo.find("SIZE").text
36
        self.filehash = fileinfo.find("CHECKSUM").text
37
38
class DownloadResult(TclResult):
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...
39
    def __init__(self, xml: str):
0 ignored issues
show
Comprehensibility Bug introduced by
xml is re-defining a name which is already available in the outer-scope (previously defined on line 3).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
40
        super().__init__(xml)
41
        root = ElementTree.fromstring(xml)
42
        file = root.find("FILE_LIST").find("FILE")
43
        self.fileid = file.find("FILE_ID").text
44
        self.fileurl = file.find("DOWNLOAD_URL").text
45
        s3_fileurl_node = file.find("S3_DOWNLOAD_URL")
46
        self.s3_fileurl = None
47
        if s3_fileurl_node is not None:
48
            self.s3_fileurl = s3_fileurl_node.text
49
        slave_list = root.find("SLAVE_LIST").findall("SLAVE")
50
        enc_list = root.find("SLAVE_LIST").findall("ENCRYPT_SLAVE")
51
        s3_slave_list = root.find("SLAVE_LIST").findall("S3_SLAVE")
52
        self.slaves = [s.text for s in slave_list]
53
        self.encslaves = [s.text for s in enc_list]
54
        self.s3_slaves = [s.text for s in s3_slave_list]
55
56
class ChecksumResult(TclResult):
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...
57
    def __init__(self, xml: str):
0 ignored issues
show
Comprehensibility Bug introduced by
xml is re-defining a name which is already available in the outer-scope (previously defined on line 3).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
58
        super().__init__(xml)
59
        root = ElementTree.fromstring(xml)
60
        file = root.find("FILE_CHECKSUM_LIST").find("FILE")
61
        self.file_addr = file.find("ADDRESS").text
62
        self.sha1_enc_footer = file.find("ENCRYPT_FOOTER").text
63
        self.sha1_footer = file.find("FOOTER").text
64
        self.sha1_body = file.find("BODY").text
65
66
class EncryptHeaderResult(TclResult):
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, contents: str):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class TclResult is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
68
        self.rawdata = contents
69