Clean up enum-related functions

This commit is contained in:
luukas 2022-05-18 01:55:05 +03:00
parent 821ed7ef5d
commit 7c85496eb8
2 changed files with 11 additions and 15 deletions

View File

@ -45,15 +45,13 @@ class PermissionsCrafty:
# **********************************************************************************
@staticmethod
def get_permissions_list():
return [
permission for _, permission in EnumPermissionsCrafty.__members__.items()
]
return list(EnumPermissionsCrafty.__members__.values())
@staticmethod
def get_permissions(permissions_mask):
return [
permission
for _, permission in EnumPermissionsCrafty.__members__.items()
for permission in EnumPermissionsCrafty.__members__.values()
if PermissionsCrafty.has_permission(permissions_mask, permission)
]
@ -81,7 +79,7 @@ class PermissionsCrafty:
@staticmethod
def get_all_permission_quantity_list():
return {name: -1 for name, _ in EnumPermissionsCrafty.__members__.items()}
return {name: -1 for name in EnumPermissionsCrafty.__members__.keys()}
@staticmethod
def get_permission_quantity_list(user_id):

View File

@ -51,15 +51,13 @@ class PermissionsServers:
@staticmethod
def get_permissions_list():
return [
permission for _, permission in EnumPermissionsServer.__members__.items()
]
return list(EnumPermissionsServer.__members__.values())
@staticmethod
def get_permissions(permissions_mask):
return [
permission
for _, permission in EnumPermissionsServer.__members__.items()
for permission in EnumPermissionsServer.__members__.values()
if PermissionsServers.has_permission(permissions_mask, permission)
]
@ -82,13 +80,13 @@ class PermissionsServers:
@staticmethod
def get_token_permissions(permissions_mask, api_permissions_mask):
permissions_list = []
for member in EnumPermissionsServer.__members__.items():
return [
permission
for permission in EnumPermissionsServer.__members__.values()
if PermissionHelper.both_have_perm(
permissions_mask, api_permissions_mask, member[1]
):
permissions_list.append(member[1])
return permissions_list
permissions_mask, api_permissions_mask, permission
)
]
# **********************************************************************************
# Role_Servers Methods