Reusable filesystem validators for Mr. Kot checks.
Project description
mr-kot-fs-validators
Reusable filesystem validator factories for Mr. Kot checks.
This package provides a set of validator factories that you compose inside your own checks using check_all().
Usage
from mr_kot import check, check_all
from mr_kot_fs_validators import (
Exists, IsFile, HasMode, OwnerIs, GroupIs
)
@check
def hosts_file_state():
return check_all(
"/etc/hosts",
Exists(),
IsFile(),
HasMode("0644"),
OwnerIs("root"),
GroupIs("root"),
)
Each validator is a small factory returning a callable: validator(target_path) -> (status, evidence).
Statuses follow Mr. Kot conventions: PASS, FAIL, ERROR (and occasionally WARN).
Evidence style
- PASS:
path=/etc/hosts exists - FAIL:
path=/data mode expected=0755 actual=0775 - FAIL(recursive):
path=/data child=/data/logs/old owner expected=mysql actual=root - ERROR:
path=/var/log error=PermissionError: [Errno 13] Permission denied
Validators
- Existence and type:
Exists,IsFile,IsDir,IsSymlink,IsSocket,IsBlockDevice,IsCharDevice. - Permissions/ownership:
HasMode,OwnerIs,GroupIs,IsExecutable,IsReadable,IsWritable. - Content/size:
Empty,SizeBetween. - State/links:
SymlinkPointsTo,RecentThan,HasSubdirs,HasFiles. - Mounts/devices/capacity:
FSTypeIs,MountExists,FreeSpaceAtLeast,DeviceAvailable. - I/O smoke:
CanReadFile,CanWriteFile.
Notes
recursive=TrueinHasMode,OwnerIs,GroupIstraverses directories withos.walkand fails on the first mismatch.follow_symlinkscontrols stat-like checks; defaultFalseunless stated otherwise.RecentThan()accepts a file path or an epoch timestamp (float or int).FSTypeIs/MountExistsparse/proc/self/mountinfoon Linux.- I/O smoke tests avoid leaving artifacts;
CanWriteFile()always removes the temporary file it creates.
Permissions shortcuts
IsExecutable(by_user=True, by_group=False, by_others=False), IsReadable(...), and IsWritable(...) accept flags to select which bits to require. If all flags are False, they fall back to checking any of the three categories.
Project details
Release history Release notifications | RSS feed
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 mr_kot_fs_validators-0.2.0.tar.gz.
File metadata
- Download URL: mr_kot_fs_validators-0.2.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.14.0-1014-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7baf6f5c9b1ff769b4dbe4e6e4e765e8b3c1584b05c01d71253cb7d1fcdf2d
|
|
| MD5 |
2efd100e5591e374880aef652b857e0d
|
|
| BLAKE2b-256 |
92ddaefd19c7a8d1342058e99ffd5f3dbafbda890d59b589d4dad7bb066c31ca
|
File details
Details for the file mr_kot_fs_validators-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mr_kot_fs_validators-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.14.0-1014-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ccc41c45bd89fac9884f708d6802bcb09f12994d1758ce35cbd04e512f62a73
|
|
| MD5 |
582c38f0dffa2f5d003d00bf22c35285
|
|
| BLAKE2b-256 |
4eb172f6efe2e7161d421b26ac9c7258426ac916b709860d91bf139db7978cf0
|