Registry / serialization / oschmod

oschmod

JSON →
library0.3.12pypypi✓ verified 83d ago

oschmod is a Python library that provides a Windows and Linux compatible `chmod` function for managing file permissions. It aims to offer a consistent API for setting POSIX-like permissions across various operating systems, including Windows, which natively uses Access Control Lists (ACLs) rather than POSIX mode bits. The current version is 0.3.12, and it maintains a moderate release cadence primarily for bug fixes and compatibility updates.

pip install oschmod
INSTALL
IMPORT
SIG · OSCHMOD
O
oschmod
serializationpythonv0.3.12
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

oschmod
import oschmod
from oschmod import oschmod

This quickstart demonstrates how to use the `oschmod` function to set file permissions. It creates a temporary file, sets its permissions to 0o755 (read, write, execute for owner; read, execute for group and others), and then verifies the change. Remember to use an octal literal (e.g., `0o755`) for the mode.

import os from oschmod import oschmod # Create a dummy file for demonstration file_path = 'my_test_file.txt' with open(file_path, 'w') as f: f.write('Hello, oschmod!') print(f"Initial permissions for {file_path}: {oct(os.stat(file_path).st_mode & 0o777)}") # Set permissions to rwxr-xr-x (0o755) oschmod(file_path, 0o755) print(f"New permissions for {file_path}: {oct(os.stat(file_path).st_mode & 0o777)}") # Clean up the dummy file os.remove(file_path)
Debug
Known issues
gotchaOn Windows, `oschmod` translates POSIX-like mode bits to Windows Access Control Lists (ACLs). This is an approximation and not all POSIX modes have direct ACL equivalents, which can lead to slightly different effective permissions or limitations compared to a true POSIX system.
fix
Be aware of potential differences in permission interpretation on Windows. For fine-grained Windows permissions, consider using a dedicated ACL management library.
affects: All versions
gotchaThe `oschmod` function is not recursive by default. It only modifies the permissions of the specified file or directory itself. To apply permissions to the contents of a directory, you must manually traverse the directory tree (e.g., using `os.walk`).
fix
Implement directory traversal logic using `os.walk` or similar methods if you need to set permissions recursively for a directory's contents.
affects: All versions
gotchaAttempting to change permissions on files or directories where the current user lacks the necessary administrative or ownership privileges will result in a `PermissionError`. This is especially common on Windows for system files or on Linux for files owned by root.
fix
Ensure the script is run with appropriate user privileges (e.g., administrator on Windows, root or sudo on Linux) or verify the current user has ownership/write permissions for the target file/directory.
affects: All versions
Upgrade
Version history
0.3.12latest on PyPI · released Oct 30, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
oschmod — pip install oschmod · libregistry