Add Docstrings to validations_libs/group.py file
Change-Id: I857a54eb2b42acbcad19f3b16b1aa9e6922dc1b9 Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
This commit is contained in:
parent
eb62054a33
commit
10e9a19f22
@ -20,7 +20,25 @@ LOG = logging.getLogger(__name__ + ".Group")
|
|||||||
|
|
||||||
|
|
||||||
class Group(object):
|
class Group(object):
|
||||||
|
"""An object for encapsulating the groups of validation
|
||||||
|
|
||||||
|
The validations can be grouped together by specifying a ``groups``
|
||||||
|
metadata. These ``groups`` are referenced in a ``groups.yaml`` file on the
|
||||||
|
filesystem.
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
group1:
|
||||||
|
- description: >-
|
||||||
|
Description of the group1
|
||||||
|
group2:
|
||||||
|
- description: >-
|
||||||
|
Description of the group2
|
||||||
|
group3:
|
||||||
|
- description: >-
|
||||||
|
Description of the group3
|
||||||
|
|
||||||
|
"""
|
||||||
def __init__(self, groups):
|
def __init__(self, groups):
|
||||||
self.data = self._get_content(groups)
|
self.data = self._get_content(groups)
|
||||||
|
|
||||||
@ -33,13 +51,53 @@ class Group(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
|
"""Get the full content of the ``groups.yaml`` file
|
||||||
|
|
||||||
|
:return: The content of the ``groups.yaml`` file
|
||||||
|
:rtype: `dict`
|
||||||
|
|
||||||
|
:Example:
|
||||||
|
|
||||||
|
>>> groups = "/foo/bar/groups.yaml"
|
||||||
|
>>> grp = Group(groups)
|
||||||
|
>>> print(grp.get_data)
|
||||||
|
{'group1': [{'description': 'Description of the group1'}],
|
||||||
|
'group2': [{'description': 'Description of the group2'}],
|
||||||
|
'group3': [{'description': 'Description of the group3'}]}
|
||||||
|
"""
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_formated_group(self):
|
def get_formated_group(self):
|
||||||
|
"""Get a formated content for output display
|
||||||
|
|
||||||
|
:return:
|
||||||
|
:rtype: `list` of `tuples`
|
||||||
|
|
||||||
|
:Example:
|
||||||
|
|
||||||
|
>>> groups = "/foo/bar/groups.yaml"
|
||||||
|
>>> grp = Group(groups)
|
||||||
|
>>> print(grp.get_formated_group)
|
||||||
|
[('group1', 'Description of the group1'),
|
||||||
|
('group2', 'Description of the group2'),
|
||||||
|
('group3', 'Description of the group3')]
|
||||||
|
"""
|
||||||
return [(gp_n, gp_d[0].get('description'))
|
return [(gp_n, gp_d[0].get('description'))
|
||||||
for (gp_n, gp_d) in sorted(self.data.items())]
|
for (gp_n, gp_d) in sorted(self.data.items())]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_groups_keys_list(self):
|
def get_groups_keys_list(self):
|
||||||
|
"""Get the list of the group name only
|
||||||
|
|
||||||
|
:return: The list of the group name
|
||||||
|
:rtype: `list`
|
||||||
|
|
||||||
|
:Example:
|
||||||
|
|
||||||
|
>>> groups = "/foo/bar/groups.yaml"
|
||||||
|
>>> grp = Group(groups)
|
||||||
|
>>> print(grp.get_groups_keys_list)
|
||||||
|
['group1', 'group2', 'group3']
|
||||||
|
"""
|
||||||
return [gp for gp in sorted(self.data.keys())]
|
return [gp for gp in sorted(self.data.keys())]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user