| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 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 | |||
| 54 |