cellpy.internals package

Contents

cellpy.internals package#

Submodules#

cellpy.internals.core module#

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

check_connection(p=None)[source]#

Check if the connection works.

This is a helper function for cellpy v1.0 only and should be removed in later versions after the OtherPath class has been updated to work with python >= 3.12.

Parameters:

p (str, pathlib.Path or OtherPath, optional) – The path to check. Defaults to prms.Paths.rawdatadir.

cellpy.internals.otherpath module#

class ExternalStatResult(st_size: int = 0, st_mtime: int = 0, st_atime: int = 0, st_ctime: int | None = None)[source]#

Bases: object

Mock of os.stat_result.

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

Bases: Path

A pathlib.Path subclass that can handle external paths.

This is the legacy version of OtherPath only valid for Python 3.11 and earlier.

is_external#

is True if the path is external.

Type:

bool

location#

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

Type:

str

uri_prefix#

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

Type:

str

raw_path#

the path without any uri_prefix or location.

Type:

str

original#

the original path string.

Type:

str

full_path#

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.

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: Path | None = None, testing=False) 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.

property full_path: str#
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.

property is_external: bool#
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

property location: str#

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

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

Return True if this path matches the given pattern.

property name#

Return the parent directory of the path.

property original: str#
property owner#

Return the login name of the file owner.

property parent: S#

Return the parent directory of the path.

property parents#

A sequence of this path’s logical parents.

property pathlike_location: S#

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

property raw_path: str#

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 | 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.

property stem: str#

Return the stem of the path.

property suffix: str#

Return the suffix of the path.

property suffixes: List[str]#

Return the suffixes of the path.

property uri_prefix: str#

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

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.

class OtherPathNew(*args, **kwargs)[source]#

Bases: Path

A pathlib.Path subclass that can handle external paths.

is_external#

is True if the path is external.

Type:

bool

location#

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

Type:

str

uri_prefix#

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

Type:

str

raw_path#

the path without any uri_prefix or location.

Type:

str

original#

the original path string.

Type:

str

full_path#

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.

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: Path | None = None, testing=False) 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.

property full_path: str#
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.

property is_external: bool#
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

property location: str#

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

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

Return True if this path matches the given pattern.

property name#

Return the parent directory of the path.

property original: str#
property owner#

Return the login name of the file owner.

property parent: S#

Return the parent directory of the path.

property parents#

A sequence of this path’s logical parents.

property pathlike_location: S#

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

property raw_path: str#

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 | 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.

property stem: str#

Return the stem of the path.

property suffix: str#

Return the suffix of the path.

property suffixes: List[str]#

Return the suffixes of the path.

property uri_prefix: str#

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

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.

check_otherpath_new()[source]#
get_otherpath_class()[source]#

Module contents#