scitacean.RemotePath#

class scitacean.RemotePath(*path_segments)[source]#

A path on the remote filesystem.

Remote paths do not need to correspond to a regular filesystem path like pathlib.PosixPath or pathlib.WindowsPath. Instead, they can be any sequence of segments that are joined by forward slashes, e.g. a URL.

RemotePath is strict about input types in order to prompt the user to think about correct, cross-platform handling of paths. In particular, there is only limited interoperability with local paths as the two should almost never be mixed.

Constructors

__init__(*path_segments)

Initialize from given path segments.

Methods

from_local(path)

Create a RemotePath from a local, OS-specific path.

to_local()

Return self as a local, OS-specific path.

truncated([max_length])

Return a new remote path with all path segments truncated.

validate(value)

Pydantic validator for RemotePath fields.

Attributes

name

The name of the file with all directories removed.

parent

The logical parent of the path.

posix

Return the path for use on a POSIX filesystem, i.e. with forward slashes.

suffix

The file extension including a leading period.

__init__(*path_segments)[source]#

Initialize from given path segments.

classmethod from_local(path)[source]#

Create a RemotePath from a local, OS-specific path.

On Windows, the drive is preserved which is likely not what you want. So it is recommended to use this function only with relative paths.

Return type:

RemotePath

property name: str#

The name of the file with all directories removed.

property parent: RemotePath#

The logical parent of the path.

property posix: str#

Return the path for use on a POSIX filesystem, i.e. with forward slashes.

property suffix: str | None#

The file extension including a leading period.

to_local()[source]#

Return self as a local, OS-specific path.

Return type:

PurePath

truncated(max_length=255)[source]#

Return a new remote path with all path segments truncated.

Parameters:

max_length (int, default: 255) – Maximum length of each segment. The default value is the typical maximum length on Linux.

Returns:

RemotePath – A new remote path with truncated segments.

classmethod validate(value)[source]#

Pydantic validator for RemotePath fields.

Return type:

RemotePath