Info, temp & errors¶
*_info returns a typed DataFrame when pandas is installed, otherwise
list[dict] rows carrying the same typed scalars.
pyrfs.file_info ¶
file_info(path: PathInput | Iterable[PathInput], *, follow: bool = False) -> pd.DataFrame | list[dict[str, object]]
Stat path(s) into a typed table.
Returns a DataFrame with typed columns (path/size/permissions
as pyrfs dtypes) when pandas is installed, else list[dict] rows of
the same typed scalars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str, os.PathLike, or iterable of them
|
Path(s) to stat. |
required |
follow
|
bool
|
Stat symlink targets instead of the links themselves
(default |
False
|
See Also
dir_info : Stat a directory's entries. pyrfs.FsPath.info : One row, as a plain dict.
Examples:
>>> file_info("pyproject.toml")
path type size permissions ...
0 pyproject.toml file 1.7K rw-r--r-- ...
pyrfs.dir_info ¶
dir_info(path: PathInput = '.', *, all: bool = False, recurse: bool | int = False, type: str | Iterable[str] = 'any', glob: str | None = None, regexp: str | None = None, invert: bool = False, fail: bool = True) -> pd.DataFrame | list[dict[str, object]]
Stat directory entries into a typed table (same filters as dir_ls).
Returns a DataFrame with typed columns when pandas is installed, else
list[dict] rows. This is the fs headline: with typed columns,
string literals work inside .query().
See Also
file_info : Stat explicit path(s). pyrfs.dir_ls : The underlying listing and its filter arguments.
Examples:
>>> (dir_info("pyrfs", recurse=True)
... .query("size > '10KB' and type == 'file'")
... .sort_values("size", ascending=False))
pyrfs.has_pandas
cached
¶
has_pandas() -> bool
Whether pandas is importable (cached; decides the *_info shape).
Examples:
>>> has_pandas() in (True, False)
True
pyrfs.file_temp ¶
file_temp(pattern: str = 'file', tmp_dir: PathInput | None = None, ext: str = '') -> FsPath
Return a unique temp path (a name only — the file is not created).
If names were queued with file_temp_push, the oldest queued name is
returned instead — deterministic mode, fs's trick for reproducible
examples, docs, and tests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Filename prefix (default |
'file'
|
tmp_dir
|
str or PathLike
|
Directory for the name (default: the session temp directory). |
None
|
ext
|
str
|
Extension, with or without the leading dot. |
''
|
See Also
file_temp_push, file_temp_pop : The deterministic-name queue. pyrfs.path_temp : The temp directory itself.
Examples:
>>> file_temp(ext="csv")
FsPath('/tmp/file2bf36b4eb5d8.csv')
>>> _ = file_temp_push("/tmp/demo.csv")
>>> file_temp() # deterministic: returns the queued name
FsPath('/tmp/demo.csv')
pyrfs.file_temp_push ¶
file_temp_push(path: PathInput | Iterable[PathInput]) -> list[FsPath]
Queue deterministic path(s) for subsequent file_temp calls.
Returns:
| Type | Description |
|---|---|
list of FsPath
|
The queued paths (FIFO order). |
Examples:
>>> file_temp_push(["/tmp/one", "/tmp/two"])
[FsPath('/tmp/one'), FsPath('/tmp/two')]
>>> file_temp(), file_temp()
(FsPath('/tmp/one'), FsPath('/tmp/two'))
pyrfs.file_temp_pop ¶
file_temp_pop() -> FsPath | None
Remove and return the oldest queued temp path (None if empty).
Examples:
>>> _ = file_temp_push("/tmp/queued")
>>> file_temp_pop()
FsPath('/tmp/queued')
>>> file_temp_pop() is None
True
pyrfs.FsError ¶
Bases: Exception
Base class for all pyrfs validation errors.