euporie.core.path
Responsible for loading data from urls.
Functions
|
Parse and resolve a path. |
Classes
|
|
|
PurePath subclass that can make system calls. |
|
|
|
A path for untitled files, as needed for LSP servers. |
- class euporie.core.path.UntitledPath(*args, protocol: str | None = None, **storage_options: Any)
Bases:
MemoryPathA path for untitled files, as needed for LSP servers.
- absolute() Self
Return an absolute version of this path No normalization or symlink resolution is performed.
Use resolve() to resolve symlinks and remove ‘..’ segments.
- property anchor
The concatenation of the drive and root, or ‘’.
- as_posix()
Return the string representation of the path with forward (/) slashes.
- chmod(mode: int, *, follow_symlinks: bool = True) None
Change the permissions of the path, like os.chmod().
- copy(target, **kwargs)
Recursively copy this file or directory tree to the given destination.
- copy_into(target_dir, **kwargs)
Copy this file or directory tree into the given existing directory.
- property drive
The drive prefix (letter or UNC path), if any.
- expanduser() Self
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
- classmethod from_uri(uri)
Return a new path from the given ‘file’ URI.
- property fs: AbstractFileSystem
The cached fsspec filesystem instance for the path.
- full_match(pattern, *, case_sensitive=None)
Return True if this path matches the given glob-style pattern. The pattern is matched against the entire path.
- glob(pattern: str, *, case_sensitive=None) Generator[UPath, None, None]
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
- hardlink_to(target: str | PathLike[str] | UPath) None
Make this path a hard link pointing to the same file as target.
Note the order of arguments (self, target) is the reverse of os.link’s.
- property info
A PathInfo object that exposes the file type and other file attributes of this path.
- is_file() bool
Whether this path is a regular file (also True for symlinks pointing to regular files).
- is_relative_to(other, /, *_deprecated) bool
Return True if the path is relative to another path or False.
- is_reserved() bool
Return True if the path contains one of the special names reserved by the system, if any.
- iterdir()
Yield path objects of the directory contents.
The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.
- joinpath(*pathsegments: str | os.PathLike[str]) Self
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(mode: int) None
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
- lstat() UPathStatResult
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
- match(path_pattern, *, case_sensitive=None)
Return True if this path matches the given pattern. If the pattern is relative, matching is done from the right; otherwise, the entire path is matched. The recursive wildcard ‘**’ is not supported by this method.
- move(target)
Recursively move this file or directory tree to the given destination.
- move_into(target_dir)
Move this file or directory tree into the given existing directory.
- open(mode: str = 'r', *args: Any, **fsspec_kwargs: Any) IO[Any]
Open the file pointed by this path and return a file object, as the built-in open() function does.
- Parameters:
mode – Opening mode. Default is ‘r’.
buffering – Default is the block size of the underlying fsspec filesystem.
encoding – Encoding is only used in text mode. Default is None.
errors – Error handling for encoding. Only used in text mode. Default is None.
newline – Newline handling. Only used in text mode. Default is None.
**fsspec_kwargs – Additional options for the fsspec filesystem.
- property parent
The logical parent of the path.
- property parents
A sequence of this path’s logical parents.
- parser = <wrapped class AnyProtocolFileSystemFlavour>
- property parts
An object providing sequence-like access to the components in the filesystem path.
- property path
The path that a fsspec filesystem can use.
- read_bytes()
Open the file in bytes mode, read it, and close the file.
- read_text(encoding=None, errors=None, newline=None)
Open the file in text mode, read it, and close the file.
- readlink() Self
Return the path to which the symbolic link points.
- relative_to(other, /, *_deprecated, walk_up=False) Self
Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not related to the other path), raise ValueError.
The walk_up parameter controls whether .. may be used to resolve the path.
- rename(target: str | os.PathLike[str] | UPath, *, recursive: bool = <object object>, maxdepth: int | None = <object object>, **kwargs: Any) Self
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- replace(target: str | PathLike[str] | UPath) UPath
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- resolve(strict: bool = False) Self
Make the path absolute, resolving all symlinks on the way and also normalizing it.
- rglob(pattern: str, *, case_sensitive=None) Generator[UPath, None, None]
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
- property root
The root of the path, if any.
- samefile(other_path) bool
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
- stat(*, follow_symlinks=True) UPathStatResult
Return the result of the stat() system call on this path, like os.stat() does.
- property stem
The final path component, minus its last suffix.
- property suffix
The final component’s last suffix, if any.
This includes the leading period. For example: ‘.txt’
- property suffixes
A list of the final component’s suffixes, if any.
These include the leading periods. For example: [‘.tar’, ‘.gz’]
- symlink_to(target: str | PathLike[str] | UPath, target_is_directory: bool = False) None
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- touch(mode=438, exist_ok=True) None
Create this file with the given access mode, if it doesn’t exist.
- unlink(missing_ok: bool = False) None
Remove this file or link. If the path is a directory, use rmdir() instead.
- walk(top_down=True, on_error=None, follow_symlinks=False)
Walk the directory tree from this directory, similar to os.walk().
- with_name(name)
Return a new path with the file name changed.
- with_segments(*pathsegments: str | os.PathLike[str]) Self
Construct a new path object from any number of path-like objects. Subclasses may override this method to customize how new path objects are created from methods like iterdir().
- with_stem(stem)
Return a new path with the stem changed.
- with_suffix(suffix)
Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
- write_bytes(data)
Open the file in bytes mode, write to it, and close the file.
- write_text(data, encoding=None, errors=None, newline=None)
Open the file in text mode, write to it, and close the file.