Class to handle Unix file permission roles (owner, group, others).
Example
>>> permissions = UnixPermissions()
>>> "owner" in permissions
> True
Class to handle Unix file permission roles (owner, group, others).
>>> permissions = UnixPermissions()
>>> "owner" in permissions
> True
Check if the provided role is valid.
@classmethod
def is_valid_role(cls, role: str) -> bool:
"""Check if the provided role is valid.
:param role: (str) The role to check among the valid roles.
"""
return role in cls.__VALID_ROLES
Return the 'owner' role.
@property
def owner(self):
"""Return the 'owner' role."""
return 'owner'
Return the 'group' role.
@property
def group(self):
"""Return the 'group' role."""
return 'group'
Return the 'others' role.
@property
def others(self):
"""Return the 'others' role."""
return 'others'
Allow iteration over VALID_ROLES.
def __iter__(self):
"""Allow iteration over VALID_ROLES."""
return iter(self.__VALID_ROLES)
Enter the context: Initialize or lock resources if needed.
def __enter__(self):
"""Enter the context: Initialize or lock resources if needed."""
return self
Exit the context: Clean up resources or handle exceptions.
def __exit__(self, exc_type, exc_value, traceback):
"""Exit the context: Clean up resources or handle exceptions.
"""
return False