GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LoadHostClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 30 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 40
ccs 0
cts 21
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 10 12 1
A main() 0 20 2

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
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
from enarksh.Credentials import Credentials
9
from enarksh.DataLayer import DataLayer
10
from enarksh.xml_reader.XmlReader import XmlReader
11
12
13
class LoadHostClient:
14
    """
15
    A client for requesting the controller to load a host definition.
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def __init__(self):
20
        """
21 View Code Duplication
        Object constructor.
22
        """
23
        credentials = Credentials.get()
24
25
        DataLayer.config['host'] = credentials.get_host()
26
        DataLayer.config['user'] = credentials.get_user()
27
        DataLayer.config['password'] = credentials.get_password()
28
        DataLayer.config['database'] = credentials.get_database()
29
        DataLayer.config['port'] = credentials.get_port()
30
        DataLayer.config['autocommit'] = False
31
32
    # ------------------------------------------------------------------------------------------------------------------
33
    def main(self, filename):
34
        """
35
        The main function of load_schedule.
36
37
        :param str filename: The filename with the XML definition of the host.
38
        """
39
        try:
40
            DataLayer.connect()
41
42
            reader = XmlReader()
43
            host = reader.parse_host(filename)
44
            host.store()
45
46
            DataLayer.commit()
47
            DataLayer.disconnect()
48
        except Exception as exception:
49
            DataLayer.rollback()
50
            DataLayer.disconnect()
51
52
            raise exception
53
54
# ----------------------------------------------------------------------------------------------------------------------
55