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.

Dependency.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
c 3
b 0
f 0
dl 0
loc 21
ccs 0
cts 5
cp 0
crap 2
rs 9.3142
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
from enarksh.DataLayer import DataLayer
9
10
11
class Dependency:
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...
12
    # ------------------------------------------------------------------------------------------------------------------
13
    def __init__(self, port):
14
        self._node_name = ''
15
        """
16
        The name of the referenced node of this dependency.
17
18
        :type: str
19
        """
20
21
        self._port = port
22
        """
23
        The port (owner) of this dependency.
24
25
        :type: enarksh.xml_reader.port.Port.Port
26
        """
27
28
        self._port_name = ''
29
        """
30
        The name of the referenced port of this dependency.
31
32
        :type: str
33
        """
34
35
    # ------------------------------------------------------------------------------------------------------------------
36
    def get_dependency_level(self):
37
        """
38
        :rtype: int
39
        """
40
        if self._node_name == '.':
41
            return -1
42
        else:
43
            return self._port.node.parent_node.get_node_by_name(self._node_name).get_dependency_level()
44
45
    # ------------------------------------------------------------------------------------------------------------------
46
    def read_xml(self, xml):
47
        """
48
        :param xml.etree.ElementTree.Element xml:
49
        """
50
        for element in list(xml):
51
            tag = element.tag
52
            if tag == 'NodeName':
53
                self._node_name = element.text
54
55
            elif tag == 'PortName':
56
                self._port_name = element.text
57
58
            else:
59
                raise RuntimeError("Unexpected tag '{0!s}'.".format(tag))
60
61
    # ------------------------------------------------------------------------------------------------------------------
62
    def validate(self, errors):
63
        """
64
        Validates this dependency against rules which are not imposed by XSD.
65
66
        :param list errors: A list of error messages.
67
        """
68
        # @todo XXX Node named $this->myNodeName must exists.
69
        # @todo XXX Node must have port named $this->myPortName.
70
        pass
71
72
    # ------------------------------------------------------------------------------------------------------------------
73
    def store(self, port, node):
74
        """
75
        Stores this dependency into the database.
76
77
        :param enarksh.xml_reader.port.Port.Port port: The port of the dependency.
78
        :param enarksh.xml_reader.node.Node.Node node: The node of the dependency.
79
        """
80
        prt_id_dependant = port.prt_id
81
        prt_id_predecessor = node.get_port_by_name(self._node_name, self._port_name).prt_id
82
83
        DataLayer.enk_reader_dependency_store_dependency(prt_id_dependant, prt_id_predecessor)
84
85
# ----------------------------------------------------------------------------------------------------------------------
86