Bytes & Perms¶
Typed scalars that subclass int — see the
typed values guide. With the [pandas] extra,
columns of these become the "bytes"/"perms"/"path" ExtensionDtypes.
pyrfs.Bytes ¶
Bases: int
A byte count that parses and displays human-readable sizes.
All units are 1024-based ("10MB" == "10MiB" == 10 * 1024**2),
matching R's fs.
Examples:
>>> Bytes("10MB")
Bytes(10485760)
>>> str(Bytes(455200))
'444.5K'
>>> Bytes(455200) < "1MB"
True
>>> str(Bytes("1MB") + "500KB")
'1.49M'
Notes
repr stays exact (Bytes(455200)); str/format humanize.
With the [pandas] extra, columns of these use the "bytes"
ExtensionDtype, so the same comparisons work in DataFrame.query().
See Also
pyrfs.file_size : Returns sizes as Bytes.
pyrfs.Perms ¶
Bases: int
Unix permission bits that parse and display rwxr-xr-x style.
Construct from octal ("644"), symbolic ("u+rw,go+r"), display
("rw-r--r--") strings, or raw mode bits.
Examples:
>>> Perms("644")
Perms('rw-r--r--')
>>> Perms("644") == "rw-r--r--"
True
>>> str(Perms("644") | "u+x")
'rwxr--r--'
Notes
Symbolic strings here build from a base of 0 (so "u+rw" ==
"u=rw"); pyrfs.file_chmod applies symbolic modes to the file's
current mode instead, like the chmod command.
See Also
pyrfs.file_chmod : Apply permissions to files.