Source code for magpie.permissions
from magpie.utils import ExtendedEnumMeta
from six import with_metaclass
from enum import Enum
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from magpie.definitions.typedefs import Iterable, List, Optional, Str, AnyPermissionType # noqa: F401
[docs]class Permission(with_metaclass(ExtendedEnumMeta, Enum)):
# file/dir permissions
[docs] READ_MATCH = u"read-match"
[docs] WRITE_MATCH = u"write-match"
# WPS permissions
[docs] GET_CAPABILITIES = u"getcapabilities"
[docs] GET_FEATURE_INFO = u"getfeatureinfo"
[docs] GET_LEGEND_GRAPHIC = u"getlegendgraphic"
[docs] GET_FEATURE = u"getfeature"
[docs] DESCRIBE_FEATURE_TYPE = u"describefeaturetype"
[docs] DESCRIBE_PROCESS = u"describeprocess"
[docs] LOCK_FEATURE = u"lockfeature"
[docs] TRANSACTION = u"transaction"
[docs]def convert_permission(permission):
# type: (AnyPermissionType) -> Optional[Permission]
"""
Converts any permission representation to the ``Permission`` enum.
If the permission cannot be matched to one of the enum's value, ``None`` is returned instead.
"""
if permission in Permission:
return permission
return Permission.get(getattr(permission, "perm_name", None) or permission)