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.
Passed
Pull Request — master (#4)
by Oleg
02:28
created

Resource.name()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 8
ccs 0
cts 2
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
import abc
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
from xml.etree.ElementTree import Element
0 ignored issues
show
Unused Code introduced by
Unused Element imported from xml.etree.ElementTree
Loading history...
3
4
5
class Resource:
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...
6
    # ------------------------------------------------------------------------------------------------------------------
7
    def __init__(self, node):
8
        self._node = node
9
        """
10
        The node that owns this resource.
11
12
        :type: Node
13
        """
14
15
        self._resource_name = ''
16
        """
17
        The name of this resource.
18
19
        :type: str
20
        """
21
22
        self._rsc_id = 0
23
        """
24
        The ID of this resource when it is stored in the databases.
25
26
        :type: int
27
        """
28
29
    # ------------------------------------------------------------------------------------------------------------------
30
    @property
31
    def name(self):
32
        """
33
        Returns the name of this resource.
34
35
        :rtype: str
36
        """
37
        return self._resource_name
38
39
    # ------------------------------------------------------------------------------------------------------------------
40
    @property
41
    def rsc_id(self):
42
        """
43
        Returns the ID of this resource.
44
45
        :rtype: str
46
        """
47
        return self._rsc_id
48
49
    # ------------------------------------------------------------------------------------------------------------------
50
    def read_xml(self, xml):
51
        """
52
        :param xml.etree.ElementTree.Element xml:
53
        """
54
        for element in list(xml):
55
            self.read_xml_element(element)
56
57
    # ------------------------------------------------------------------------------------------------------------------
58
    def read_xml_element(self, xml):
59
        """
60
        :param xml.etree.ElementTree.Element xml:
61
        """
62
        tag = xml.tag
63
        if tag == 'ResourceName':
64
            self._resource_name = xml.text
65
66
        else:
67
            Resource.read_xml_element(self, xml)
68
69
    # ------------------------------------------------------------------------------------------------------------------
70
    def get_uri(self, obj_type='resource'):
71
        """
72
        Returns the URI of this resource.
73
74
        :param str obj_type: The entity type.
75
76
        :rtype: str
77
        """
78
        if self._node:
79
            uri = self._node.get_uri(obj_type)
80
        else:
81
            uri = '//' + obj_type
82
83
        return uri + '/' + self._resource_name
84
85
    # ------------------------------------------------------------------------------------------------------------------
86
    @abc.abstractmethod
87
    def store(self, hst_id, nod_id):
88
        """
89
        :param int hst_id:
90
        :param int nod_id:
91
        """
92
        pass
93
94
    # ------------------------------------------------------------------------------------------------------------------
95
    def validate(self, errors):
96
        """
97
        Validates this resource against rules which are not imposed by XSD.
98
99
        :param list errors: A list of error messages.
100
        """
101
        # Nothing to do.
102
103
104
# ----------------------------------------------------------------------------------------------------------------------
105