Quick reference guide¶
This is a cheatsheet for common tasks in Plumbum.
CLI¶
Optional arguments¶
Utility |
Usage |
---|---|
|
True or False descriptor |
|
A value as a descriptor |
|
Counting version of |
|
A function that runs when passed |
|
A switch that gets its name from the function decorated |
|
A positional argument validator on main (or use Py3 attributes) |
Validators¶
Anything that produces a ValueError
or TypeError
, is applied to argument. Some special ones included:
Validator |
Usage |
---|---|
|
A number in some range |
|
A choice in a set |
|
A file (converts to Path) |
|
A directory |
|
Not a file or directory |
Common options¶
Option |
Used in |
Usage |
---|---|---|
First argument |
Non-auto |
The name, or list of names, includes dash(es) |
Second argument |
All |
The validator |
docstring |
|
The help message |
|
All |
The help message |
|
|
Allow multiple times (passed as list) |
|
All |
A list of optional arguments to require |
|
All |
A list of optional arguments to exclude |
|
All |
The name of a group |
|
All |
The default if not given |
|
|
The name of an environment variable to check |
|
Switches |
Require this argument to be passed |
Special member variables¶
Paths¶
Idiom |
Description |
---|---|
|
Common way to make paths |
|
Composition of parts |
|
Grep for files |
Sorting |
Alphabetical |
Iteration |
By parts |
To str |
Canonical full path |
Subtraction |
Relative path |
|
Check for file in folder |
Property |
Description |
Compare to Pathlib |
---|---|---|
|
The file name |
✓ |
|
DEPRECATED |
|
|
Name without extension |
✓ |
|
Directory name |
✗ |
|
The file tree root |
✓ |
|
Drive letter (Windows) |
✓ |
|
The suffix |
✓ |
|
A list of suffixes |
✓ |
|
User ID |
✗ |
|
Group ID |
✗ |
|
Tuple of |
✓ |
|
The ancestors of the path |
✓ |
|
The ancestor of the path |
✓ |
Method |
Description |
Compare to Pathlib |
---|---|---|
|
Go up count directories |
✗ |
|
Traverse directories |
✗ |
|
Universal Resource ID |
✓ |
|
Put together paths ( |
|
|
Files in directory |
✗ (shortcut) |
|
Fast iterator over dir |
✓ |
|
If path is dir |
✓ |
|
DEPRECATED |
|
|
If is file |
✓ |
|
DEPRECATED |
|
|
If is symlink |
✓ |
|
DEPRECATED |
|
|
If file exists |
✓ |
|
Return OS stats |
✓ |
|
Replace filename |
✓ |
|
Replace suffix |
✓ (no depth) |
|
Replace suffix if no suffix |
✗ |
|
Search for pattern |
✓ |
|
Split into directories |
|
|
Relative path ( |
✓ |
|
Does nothing |
✓ |
|
Check access permissions |
✗ |
Method (changes files) |
Description |
Compare to Pathlib |
---|---|---|
|
Make a hard link |
✗ |
|
Make a symlink |
|
|
Unlink a file (delete) |
✓ |
|
Delete file |
|
|
Move file |
✗ |
|
Change the file name |
✓ |
|
Copy a file |
✗ |
|
Make a directory |
✓ (+ more args) |
|
Open a file for reading |
✓ (+ more args) |
|
Read a file to text |
|
|
Write to a file |
|
|
Touch a file |
✓ (+ more args) |
|
Change owner |
✗ |
|
Change permissions |
✓ |
Colors¶
You pick colors from fg
or bg
, also can reset
Main colors: black
red
green
yellow
blue
magenta
cyan
white
Default styles: warn
title
fatal
highlight
info
success
Attrs: bold
dim
underline
italics
reverse
strikeout
hidden