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:
objectMock 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:
PathA 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
- rglob(method)[source]#
a method for ‘recursive’ globbing external paths (max one extra level deep) if
is_externalis 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.
- connection_info(testing: bool = False) Tuple[Dict, str][source]#
Return a dictionary with connection information.
- 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.
- property is_external: bool#
- 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
OtherPathobjects.- Return type:
Generator
- property location: str#
Return the location of the external path (e.g
user@server.com).
- 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#
- 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://).
- class OtherPathNew(*args, **kwargs)[source]#
Bases:
PathA 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
- rglob(method)[source]#
a method for ‘recursive’ globbing external paths (max one extra level deep) if
is_externalis 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.
- connection_info(testing: bool = False) Tuple[Dict, str][source]#
Return a dictionary with connection information.
- 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.
- property is_external: bool#
- 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
OtherPathobjects.- Return type:
Generator
- property location: str#
Return the location of the external path (e.g
user@server.com).
- 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#
- 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://).