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.

Port.name()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 2
cp 0
crap 2
rs 9.4285
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import abc
9
10
from enarksh.xml_reader.Dependency import Dependency
11
12
13
class Port(metaclass=abc.ABCMeta):
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...
14
    # ------------------------------------------------------------------------------------------------------------------
15
    def __init__(self, node):
16
        self._dependencies = []
17
        """
18
        The dependencies of this port.
19
20
        :type: list[enarksh.xml_reader.Dependency.Dependency]
21
        """
22
23
        self._node = node
24
        """
25
        The node (owner) of this port.
26
27
        :type: enarksh.xml_reader.node.Node.Node
28
        """
29
30
        self._port_name = ''
31
        """
32
        The port name of this port.
33
34
        :type: str
35
        """
36
37
        self._prt_id = 0
38
        """
39
        The ID of this port when it is stored in the database.
40
41
        :type: int
42
        """
43
44
    # ------------------------------------------------------------------------------------------------------------------
45
    @property
46
    def name(self):
47
        """
48
        Returns the name of this port.
49
50
        :rtype: str
51
        """
52
        return self._port_name
53
54
    # ------------------------------------------------------------------------------------------------------------------
55
    @property
56
    def node(self):
57
        """
58
        Returns the node of this port.
59
60
        :rtype: enarksh.xml_reader.node.Node.Node
61
        """
62
        return self._node
63
64
    # ------------------------------------------------------------------------------------------------------------------
65
    @property
66
    def prt_id(self):
67
        """
68
        Returns the ID of this port.
69
70
        :rtype: int
71
        """
72
        return self._prt_id
73
74
    # ------------------------------------------------------------------------------------------------------------------
75
    def read_xml(self, xml):
76
        """
77
        :param xml.etree.ElementTree.Element xml:
78
        """
79
        for element in list(xml):
80
            self.read_xml_element(element)
81
82
    # ------------------------------------------------------------------------------------------------------------------
83
    def read_xml_element(self, xml):
84
        """
85
        :param xml.etree.ElementTree.Element xml:
86
        """
87
        tag = xml.tag
88
        if tag == 'PortName':
89
            self._port_name = xml.text
90
91
        elif tag == 'Dependencies':
92
            self._read_xml_dependencies(xml)
93
94
        else:
95
            raise Exception("Unexpected tag '{0!s}'.".format(tag))
96
97
    # ------------------------------------------------------------------------------------------------------------------
98
    def _read_xml_dependencies(self, xml):
99
        """
100
        :param xml.etree.ElementTree.Element xml:
101
        """
102
        for element in list(xml):
103
            tag = element.tag
104
            if tag == 'Dependency':
105
                dependency = Dependency(self)
106
                dependency.read_xml(element)
107
                self._dependencies.append(dependency)
108
109
            else:
110
                raise Exception("Unexpected tag '{0!s}'.".format(tag))
111
112
    # ------------------------------------------------------------------------------------------------------------------
113
    def validate(self, errors):
114
        """
115
        Validates this port against rules which are not imposed by XSD.
116
117
        :param list errors: A list of error messages.
118
        """
119
        for dependency in self._dependencies:
120
            dependency.validate(errors)
121
122
    # ------------------------------------------------------------------------------------------------------------------
123
    @abc.abstractmethod
124
    def store(self, nod_id):
125
        """
126
        Stores the definition of this port into the database.
127
128
        :param int nod_id: The ID of the node to which this node belongs
129
        """
130
        raise NotImplementedError()
131
132
    # ------------------------------------------------------------------------------------------------------------------
133
    @abc.abstractmethod
134
    def store_dependencies(self):
135
        """
136
        Stores the dependencies of this port into the database.
137
        """
138
        raise NotImplementedError()
139
140
# ----------------------------------------------------------------------------------------------------------------------
141