Passed
Push — master ( 4b3140...3dcfbb )
by P.R.
01:38
created

Consumption.generate_xml_common()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 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 Consumption:
13
    """
14
    Class for generating XML messages for elements of type 'ConsumptionType'.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def __init__(self, name):
19
        """
20
        Object constructor.
21
        """
22
23
        self._name = name
24
        """
25
        The name of this consumption.
26
27
        :type: str
28
        """
29
30
    # ------------------------------------------------------------------------------------------------------------------
31
    @abc.abstractmethod
32
    def generate_xml(self, parent):
33
        """
34
        Generates the XML element for this consumption.
35
36
        :param xml.etree.ElementTree.Element parent: The parent XML element.
37
38
        :rtype: None
39
        """
40
        raise NotImplementedError()
41
42
    # ------------------------------------------------------------------------------------------------------------------
43
    def generate_xml_common(self, parent):
44
        """
45
        Generates the common XML elements of the XML element for this consumption.
46
47
        :param xml.etree.ElementTree.Element parent: The parent XML element (i.e. the consumption XML element).
48
        """
49
        resource_name = SubElement(parent, 'ResourceName')
50
        resource_name.text = self._name
51
52
# ----------------------------------------------------------------------------------------------------------------------
53