Exemple #1
0
    def get_group(group=None):
        """Gets a Group instance.

        Args:

            group: A dict consisting of either an id key or name key
                describing the group.

        Returns:

            A Group instance if found, None otherwise.
        """

        if(
            not group
            or not isinstance(group, dict)
            or not (
                group.get(GroupKey.Id) or group.get(GroupKey.Name)
            )
        ):
            return None

        if group.get('id'):

            g = _db.get_group(_id=group[GroupKey.Id])

        else:

            g = _db.get_group(name=group[GroupKey.Name])

        return g
Exemple #2
0
    def get_group(group=None):
        """Gets a Group instance.

        Args:

            group: A dict consisting of either an id key or name key
                describing the group.

        Returns:

            A Group instance if found, None otherwise.
        """

        if (not group or not isinstance(group, dict)
                or not (group.get(GroupKey.Id) or group.get(GroupKey.Name))):
            return None

        if group.get('id'):

            g = _db.get_group(_id=group[GroupKey.Id])

        else:

            g = _db.get_group(name=group[GroupKey.Name])

        return g
Exemple #3
0
    def get_groups(name=None):
        """Gets a list of Group instances.

        Args:

            name: Name of the groups wanted.

        Returns:

            A list of Group instances if found, empty list otherwise.
        """

        if not name:
            return []

        g = _db.get_group(name=name, all_groups=True)

        return g
Exemple #4
0
    def get_groups(name=None):
        """Gets a list of Group instances.

        Args:

            name: Name of the groups wanted.

        Returns:

            A list of Group instances if found, empty list otherwise.
        """

        if not name:
            return []

        g = _db.get_group(name=name, all_groups=True)

        return g