Registry / devops / pygnuutils

pygnuutils

JSON →
library0.1.1pypypi✓ verified 88d ago

pygnuutils is a pure Python implementation for various GNU core utilities, aiming to provide similar functionality in a Pythonic way. It is currently at version 0.1.1 and has a moderate release cadence, with the last update over a year ago.

pip install pygnuutils
INSTALL
IMPORT
SIG · PYGNUUTILS
P
pygnuutils
devopspythonv0.1.1
Install
1.7s avg
Import
54ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.1 · 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.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.056s · 18.9MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.7s · import 0.052s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

Ls
✓ from pygnuutils.ls import Ls
✗ from pygnuutils import ls
Utilities are exposed as classes within their respective modules (e.g., 'ls' utility is 'Ls' class in 'pygnuutils.ls').
Basename
✓ from pygnuutils.basename import Basename
Similar pattern for other utilities like 'Basename', 'Basenc', 'Yes', 'Filevercmp'.

This quickstart demonstrates how to initialize and use the `Ls` utility to emulate `ls` commands with Pythonic arguments. It also includes an advanced example of dependency injection, a core feature of `pygnuutils`, to customize behavior like symlink resolution.

from pygnuutils.ls import Ls # Instantiate the Ls utility ls = Ls() # List contents of the current directory, similar to 'ls -a' print("Current directory (ls -a):") ls('.', all_=True) # Note: 'all_' for '-a' argument # List contents of a specific directory in long format, similar to 'ls -l /tmp' print("\n/tmp directory (ls -l):") ls('/tmp', long=True) # Example with dependency injection (a key feature mentioned in README) import os class ReadlinkWatch(Ls.stub): def readlink(self, path, dir_fd=None): print(f'Resolving symlink: {path}...') return os.readlink(path, dir_fd=dir_fd) ls_with_watch = Ls(stub=ReadlinkWatch()) print("\nListing with symlink watcher:") # This might require creating a symlink in /tmp for demonstration # Example: os.symlink('/etc/passwd', '/tmp/mylink') # For safe execution, we won't create it here, but demonstrate the call. try: ls_with_watch('/tmp', long=True) except OSError as e: print(f"Could not complete symlink watch example: {e}") print("To run, ensure you have symlinks in /tmp or create one, e.g., 'os.symlink('/etc/passwd', '/tmp/mylink')'")
Debug
Known issues
gotchapygnuutils is a pure Python re-implementation. It may not offer full feature parity, exact behavioral equivalence, or the same performance as the native C-based GNU utilities, especially for edge cases or large-scale I/O.
fix
Always test `pygnuutils` in your environment, particularly when migrating scripts that rely on specific native GNU utility behaviors or performance characteristics.
affects: All versions
gotchaCommand-line arguments are translated to Pythonic keyword arguments (e.g., `-a` becomes `all_=True`, `-l` becomes `long=True`). The exact mapping might not be immediately obvious or cover all native GNU options.
fix
Consult the source code or specific utility documentation (if available) for the correct Python keyword arguments. Avoid directly passing string flags as you would in a shell.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pygnuutils'
The `pygnuutils` package is not installed in the active Python environment.
fix
Run `pip install pygnuutils` to install the library.
TypeError: Ls() got an unexpected keyword argument 'some_flag'
You are attempting to pass a command-line style flag (e.g., `-R`) directly as a keyword argument, but the Python wrapper expects a specific Pythonic argument name (e.g., `recursive=True`).
fix
Check the `pygnuutils` source code or documentation for the specific utility to find the correct Python keyword argument. For `Ls`, common arguments include `all_`, `long`, `recursive`, etc.
Upgrade
Version history
0.1.1latest on PyPI · released May 12, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
pygnuutils — pip install pygnuutils · libregistry