Beispiel #1
0
def get_user_list(users_module, add_default=False, add_if_not_empty=False):
    """Get list of users from the Users DBus module.

    If add_default is True we will add an empty UserData instance as the first element
    of the list, so that the UIs don't have to handle that themselves.

    :param users_module: Users DBus module proxy
    :param bool add_default: if True add default user as first list element
    :returns: list of users from the Users DBus module
    :rtype: list
    """

    user_data_list = UserData.from_structure_list(users_module.Users)

    if add_default:
        # we only add default user to an empty list, to add default user to
        # a populated list the add_if_not_empty option needs to be used
        if not user_data_list or add_if_not_empty:
            user_data_list.insert(0, UserData())

    return user_data_list
    def Users(self, users: List[Structure]):
        """Set a list of users, each corresponding to a single user.

        :param users: a list of user describing DBus structures
        """
        self.implementation.set_users(UserData.from_structure_list(users))