.keys() now returns a generator, gotta wrap it in a list() for what we do here

This commit is contained in:
Alexandre Aubin 2021-01-01 04:07:16 +01:00
parent 5f0b1b7450
commit 0335bcbf4c

View file

@ -540,7 +540,7 @@ def user_group_list(short=False, full=False, include_primary_groups=True):
groups[name]["permissions"] = [_ldap_path_extract(p, "cn") for p in infos.get("permission", [])]
if short:
groups = groups.keys()
groups = list(groups.keys())
return {'groups': groups}
@ -625,7 +625,7 @@ def user_group_delete(operation_logger, groupname, force=False, sync_perm=True):
from yunohost.permission import permission_sync_to_user
from yunohost.utils.ldap import _get_ldap_interface
existing_groups = user_group_list()['groups'].keys()
existing_groups = list(user_group_list()['groups'].keys())
if groupname not in existing_groups:
raise YunohostError('group_unknown', group=groupname)
@ -633,7 +633,7 @@ def user_group_delete(operation_logger, groupname, force=False, sync_perm=True):
# without the force option...
#
# We also can't delete "all_users" because that's a special group...
existing_users = user_list()['users'].keys()
existing_users = list(user_list()['users'].keys())
undeletable_groups = existing_users + ["all_users", "visitors"]
if groupname in undeletable_groups and not force:
raise YunohostError('group_cannot_be_deleted', group=groupname)
@ -669,7 +669,7 @@ def user_group_update(operation_logger, groupname, add=None, remove=None, force=
from yunohost.permission import permission_sync_to_user
from yunohost.utils.ldap import _get_ldap_interface
existing_users = user_list()['users'].keys()
existing_users = list(user_list()['users'].keys())
# Refuse to edit a primary group of a user (e.g. group 'sam' related to user 'sam')
# Those kind of group should only ever contain the user (e.g. sam) and only this one.