Resource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 12 1
A generate_xml() 0 10 1
A _generate_xml_common() 0 8 1
1
"""
2
Enarksh
3
4
Copyright 2015-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import abc
9
from xml.etree.ElementTree import SubElement
10
11
12
class Resource(metaclass=abc.ABCMeta):
13
    """
14
    Class for generating XML messages for elements of type 'ResourceType'.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def __init__(self, name):
19
        """
20
        Object constructor.
21
22
        :param str name: The name of this resource.
23
        """
24
        self.name = name
25
        """
26
        The name of this resource.
27
28
        :type: str
29
        """
30
31
    # ------------------------------------------------------------------------------------------------------------------
32
    @abc.abstractmethod
33
    def generate_xml(self, parent):
34
        """
35
        Generates the XML element for this resource.
36
37
        :param xml.etree.ElementTree.Element parent: The parent XML element.
38
39
        :rtype: None
40
        """
41
        raise NotImplementedError()
42
43
    # ------------------------------------------------------------------------------------------------------------------
44
    def _generate_xml_common(self, parent):
45
        """
46
        Generates the common XML elements of the XML element for this
47
48
        :param xml.etree.ElementTree.Element parent: The parent XML element (i.e. the resource XML element).
49
        """
50
        resource_name = SubElement(parent, 'ResourceName')
51
        resource_name.text = self.name
52
53
# ----------------------------------------------------------------------------------------------------------------------
54