cellpy.internals.core#

This module contains div classes etc that are not really connected to cellpy.

Module Contents#

Classes#

ExternalStatResult

Mock of os.stat_result.

OtherPath

A pathlib.Path subclass that can handle external paths.

Attributes#

ENV_VAR_CELLPY_KEY_FILENAME

ENV_VAR_CELLPY_PASSWORD

IMPLEMENTED_PROTOCOLS

S

URI_PREFIXES

class ExternalStatResult[source]#

Mock of os.stat_result.

st_atime: int = 0[source]#
st_ctime: int | None[source]#
st_mtime: int = 0[source]#
st_size: int = 0[source]#
class OtherPath(*args, **kwargs)[source]#

Bases: pathlib.Path

Inheritance diagram of cellpy.internals.core.OtherPath

A pathlib.Path subclass that can handle external paths.

is_external[source]#

is True if the path is external.

Type:

bool

location[source]#

the location of the external path (e.g. a server name).

Type:

str

uri_prefix[source]#

the prefix of the external path (e.g. scp:// or sftp://).

Type:

str

raw_path[source]#

the path without any uri_prefix or location.

Type:

str

original[source]#

the original path string.

Type:

str

full_path[source]#

the full path (including uri_prefix and location).

Type:

str

copy(method)[source]#

a method for copying the file to a local path.

glob(method)[source]#

a method for globbing external paths if is_external is True.

rglob(method)[source]#

a method for ‘recursive’ globbing external paths (max one extra level deep) if is_external is True.

Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.

property full_path: str[source]#
property is_external: bool[source]#
property location: str[source]#

Return the location of the external path (e.g user@server.com).

property name[source]#

Return the parent directory of the path.

property original: str[source]#
property owner[source]#

Return the login name of the file owner.

property parent: S[source]#

Return the parent directory of the path.

property parents[source]#

A sequence of this path’s logical parents.

property pathlike_location: S[source]#

Return the location of the external path as a pathlike object.

property raw_path: str[source]#
property stem: str[source]#

Return the stem of the path.

property suffix: str[source]#

Return the suffix of the path.

property suffixes: List[str][source]#

Return the suffixes of the path.

property uri_prefix: str[source]#

Return the uri prefix for the external path (e.g ssh://).

absolute() S[source]#

Return an absolute version of this path by prepending the current working directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

as_uri() str[source]#

Return the path as a uri (e.g. scp://user@server.com/home/data/my_file.txt).

connection_info(testing: bool = False) Tuple[Dict, str][source]#

Return a dictionary with connection information.

copy(destination: pathlib.Path | None = None, testing=False) pathlib.Path[source]#

Copy the file to a destination.

cwd()[source]#

Return a new path pointing to the current working directory.

exists(*args, **kwargs) bool[source]#

Check if path exists.

glob(glob_str: str, *args, **kwargs) Generator[source]#

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group()[source]#

Return the group name of the file gid.

is_dir(*args, **kwargs) bool[source]#

Check if path is a directory.

is_file(*args, **kwargs) bool[source]#

Check if path is a file.

iterdir(*args, **kwargs)[source]#

Yield path objects of the directory contents.

The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.

joinpath(*args, **kwargs)[source]#

Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored).

lchmod(*args, **kwargs)[source]#

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

listdir(levels: int = 1, **kwargs) Generator[source]#

List the contents of the directory.

Parameters:

levels (int, optional) –

How many sublevels to list:

  • If you want to list all sublevels, use listdir(levels=-1).

  • If you want to list only the current level (no subdirectories), use listdir(levels=0).

Returns:

Generator of OtherPath objects.

Return type:

Generator

match(*args, **kwargs)[source]#

Return True if this path matches the given pattern.

Return the path to which the symbolic link points.

resolve(*args, **kwargs) S[source]#

Resolve the path.

rglob(glob_str: str, *args, **kwargs) Generator[source]#

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

samefile(other_path: str | pathlib.Path | S) bool[source]#

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat(*args, **kwargs)[source]#

Return the result of the stat() system call on this path, like os.stat() does.

with_name(name: str) S[source]#

Return a new path with the name changed.

with_stem(stem: str) S[source]#

Return a new path with the stem changed.

with_suffix(suffix: str) S[source]#

Return a new path with the suffix changed.

ENV_VAR_CELLPY_KEY_FILENAME = 'CELLPY_KEY_FILENAME'[source]#
ENV_VAR_CELLPY_PASSWORD = 'CELLPY_PASSWORD'[source]#
IMPLEMENTED_PROTOCOLS = ['ssh:', 'sftp:', 'scp:'][source]#
S[source]#
URI_PREFIXES = ['ssh:', 'sftp:', 'scp:', 'http:', 'https:', 'ftp:', 'ftps:', 'smb:'][source]#