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
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
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