fs

Functions

exists

Check for the existance of a local/remote file.

join

Join parts into a path

open

Open a file handler to a local or remote file.

laminar.utils.fs.exists(*, uri: str) bool

Check for the existance of a local/remote file.

Usage:

fs.exists("file:///...")
fs.exists("s3://...")
Parameters
uri: str

URI to the file to check.

Returns

True if the file exists, else False.

Return type

bool

laminar.utils.fs.join(*parts: Any) str

Join parts into a path

Parameters
*parts

Parts to use to construct the URI.

Returns

Parts joined together

laminar.utils.fs.open(uri: str, mode: 'r') TextIO
laminar.utils.fs.open(uri: str, mode: 'rb') BinaryIO
laminar.utils.fs.open(uri: str, mode: 'w') TextIO
laminar.utils.fs.open(uri: str, mode: 'wb') BinaryIO

Open a file handler to a local or remote file.

Usage:

with fs.open("file:///...", "r") as file: ...
with fs.open("s3://...", "wb") as file: ...
Parameters
uri: str

URI to the file to open.

mode: 'r'
mode: 'rb'
mode: 'w'
mode: 'wb'

Mode to open the file with.

Returns

File handle to the local/remote file.

Return type

Union[BinaryIO, TextIO]