Manage and interpret Unix file permissions with a Python package that provides intuitive tools for creating, validating, and describing permission modes.
Project description
unix-perms
Manage and interpret Unix file permissions with a Python package that provides intuitive tools for creating, validating, and describing permission modes.
📦 Installation
To install unix-perms, run the following command:
pip install unix-perms
🚀 Features
- Convert octal digits to permission configurations.
- Convert octal representations to Unix permission modes.
- Validate Unix permission modes.
- Create, update, and work with permissions modes using python objects.
📚 Usage
Convert an Octal Digit to Configuration
from unix_perms import from_octal_digit_to_config
config = from_octal_digit_to_config(7)
print(config)
OctalConfig(
description='Read, write, and execute permissions',
read=True,
write=True,
execute=True
)
Convert Octal Representation to Unix Permissions Mode
from unix_perms import from_octal_to_permissions_mode
mode = from_octal_to_permissions_mode(0o777)
print(mode)
777
Validate if an Octal Representation is a Unix Permissions Mode
from unix_perms import is_permissions_mode
print(is_permissions_mode('755'))
print(is_permissions_mode('999'))
True
False
Using PermissionsConfig
from unix_perms import PermissionsConfig
config = PermissionsConfig.from_octal_digit(4)
print(config)
PermissionsConfig(read=True, write=False, execute=False)
Using PermissionsByte
from unix_perms import PermissionsByte, PermissionsConfig
config = PermissionsConfig(read=True, write=False, execute=False)
owner_permissions = PermissionsByte(authority="owner", config=config)
print(owner_permissions.permissions_mode)
print(owner_permissions.permissions_description)
400
Read permission only
Using PermissionsMode
from unix_perms import PermissionsByte, PermissionsConfig, PermissionsMode
owner_permissions = PermissionsByte(
authority="owner", config=WRITE_PERMISSIONS_CONFIG
)
group_permissions = PermissionsByte(
authority="group", config=ALL_PERMISSIONS_CONFIG
)
others_permissions = PermissionsByte(
authority="others", config=READ_PERMISSIONS_CONFIG
)
permissions_mode = PermissionsMode(
owner=owner_permissions, group=group_permissions, others=others_permissions
)
print(permissions_mode.permissions_mode)
group_permissions_new = PermissionsByte(
authority="group", config=ALL_PERMISSIONS_CONFIG
)
permission_mode_sub = permissions_mode - group_permissions_new
print(permission_mode_sub.permissions_mode)
274
204
🤝 License
This project is licensed under the MIT License. See the LICENSE file for more details.
📞 Contact
If you have any questions or need support, feel free to reach out by opening an issue on the GitHub repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unix_perms-0.6.0.tar.gz.
File metadata
- Download URL: unix_perms-0.6.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b73d3bfa56f40aeeb788281267ff678ad44a9f1b9dd137dfc9db00ea36b1242b
|
|
| MD5 |
ddd9d7a97d5760ed7472441b614cd851
|
|
| BLAKE2b-256 |
1c2bac01d6cb8828ce97f6aa1e4844e34f50a49ca57d63a50f26f548f177e6d4
|
File details
Details for the file unix_perms-0.6.0-py3-none-any.whl.
File metadata
- Download URL: unix_perms-0.6.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0d88b3ff86faac6582a2d670d996d4bf1f59eeb84b43e143d85a08785114e1f
|
|
| MD5 |
985602f22f658bd491d2f9fe069af5b4
|
|
| BLAKE2b-256 |
a9433c174ad65d3a3c1fe41082d7141da9fa2ee23f23df8d174dcb9e01f78927
|