euporie.core.path

Responsible for loading data from urls.

Functions

fs_register_implementation(name, cls[, ...])

Add implementation class to the registry

overload(func)

Decorator for overloaded functions/methods.

parse_path(path[, resolve])

Parse and resolve a path.

unquote(string[, encoding, errors])

Replace %xx escapes by their single-character equivalent.

urljoin(base, url[, allow_fragments])

Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.

urlunsplit(components)

Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string.

Classes

CachingHTTPAccessor(parsed_url, **kwargs)

A :py:module:`universal_pathlib` accessor which caches content.

ClientResponse(method, url, *, writer, ...)

DataPath(*args, **kwargs)

A pathlib compatible class for reading data URIs.

FsHTTPFileSystem

alias of fsspec.implementations.http.HTTPFileSystem

HTTPFileSystem(*args, **kwargs)

A HTTPFileSystem which does not raise exceptions on 404 errors.

HTTPPath(*args, **kwargs)

An HTTP path which caches content.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

UPath(*args, **kwargs)

WholeFileCacheFileSystem(*args, **kwargs)

Caches whole remote files on first access

class euporie.core.path.CachingHTTPAccessor(parsed_url: SplitResult | None, **kwargs: Any)

Bases: upath.implementations.http._HTTPAccessor

A :py:module:`universal_pathlib` accessor which caches content.

exists(path, **kwargs)
glob(_path, path_pattern, **kwargs)
info(path, **kwargs)
listdir(path, **kwargs)
makedirs(path, exist_ok=False, **kwargs)
mkdir(path, create_parents=True, **kwargs)
open(path, mode='r', *args, **kwargs)
rm(path, recursive, **kwargs)
stat(path, **kwargs)
touch(path, **kwargs)
class euporie.core.path.DataPath(*args: str | PathLike, **kwargs: Any)

Bases: upath.core.UPath

A pathlib compatible class for reading data URIs.

absolute() upath.core.PT

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.

property anchor

The concatenation of the drive and root, or ‘’.

as_posix()

Return the string representation of the path with forward (/) slashes.

as_uri()

Return the path as a ‘file’ URI.

chmod(mode, *, follow_symlinks: bool = True) None

Change the permissions of the path, like os.chmod().

cwd()

Return a new path pointing to the current working directory (as returned by os.getcwd()).

property drive

The drive prefix (letter or UNC path), if any.

exists(**kwargs: Any) bool

Affirm tat data URIs always exist.

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

property fs: AbstractFileSystem
glob(pattern: str) Generator[PT, None, None]

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

group()

Return the group name of the file gid.

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.

home()

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

is_absolute() bool

True if the path is absolute (has both a root and, if applicable, a drive).

is_block_device() bool

Whether this path is a block device.

is_char_device() bool

Whether this path is a character device.

is_dir() bool

Whether this path is a directory.

is_fifo() bool

Whether this path is a FIFO.

is_file() bool

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount() bool

Check if this path is a POSIX mount point

is_relative_to(*other)

Return True if the path is relative to another path or False.

is_reserved()

Return True if the path contains one of the special names reserved by the system, if any.

is_socket() bool

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir() Generator[PT, None, None]

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

joinpath(*args)

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)

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

Make the target path a hard link pointing to this path.

Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.

Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.

lstat()

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)

Return True if this path matches the given pattern.

mkdir(mode: int = 511, parents: bool = False, exist_ok: bool = False) None

Create a new directory at this given path.

property name

The final path component, if any.

open(mode: OpenTextMode = 'r', buffering: int = - 1, encoding: str | None = None, errors: str | None = None, newline: str | None = None) TextIOWrapper
open(mode: OpenBinaryMode, buffering: Literal[0], encoding: None = None, errors: None = None, newline: None = None) FileIO
open(mode: OpenBinaryModeUpdating, buffering: Literal[- 1, 1] = - 1, encoding: None = None, errors: None = None, newline: None = None) BufferedRandom
open(mode: OpenBinaryModeWriting, buffering: Literal[- 1, 1] = - 1, encoding: None = None, errors: None = None, newline: None = None) BufferedWriter
open(mode: OpenBinaryModeReading, buffering: Literal[- 1, 1] = - 1, encoding: None = None, errors: None = None, newline: None = None) BufferedReader
open(mode: OpenBinaryMode, buffering: int = - 1, encoding: None = None, errors: None = None, newline: None = None) BinaryIO
open(mode: str, buffering: int = - 1, encoding: str | None = None, errors: str | None = None, newline: str | None = None) IO[Any]

Return an io object for the data in the URI.

owner()

Return the login name of the file owner.

property parent: upath.core.PT

The logical parent of the path.

property parents: upath.core._UPathParents

A sequence of this upath’s logical parents.

property parts

An object providing sequence-like access to the components in the filesystem path.

property path: str
read_bytes()

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None)

Open the file in text mode, read it, and close the file.

Return the path to which the symbolic link points.

relative_to(*other: str | os.PathLike) upath.core.PT

Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.

rename(target)

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)

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) upath.core.PT

Return a new path with ‘.’ and ‘..’ parts normalized.

rglob(pattern: str) Generator[PT, None, None]

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

rmdir(recursive: bool = True) None

Add warning if directory not empty assert is_dir?

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()

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’]

Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.

touch(*args: int, truncate: bool = True, **kwargs) None

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

with_name(name: str) upath.core.PT

Return a new path with the file name changed.

with_stem(stem)

Return a new path with the stem changed.

with_suffix(suffix: str) upath.core.PT

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.

class euporie.core.path.HTTPFileSystem(*args, **kwargs)

Bases: fsspec.implementations.http.HTTPFileSystem

A HTTPFileSystem which does not raise exceptions on 404 errors.

async_impl = True
blocksize = 4194304
cachable = True
cat(path, recursive=False, on_error='raise', **kwargs)

Fetch (potentially multiple) paths’ contents

Parameters
  • recursive (bool) – If True, assume the path(s) are directories, and get all the contained files

  • on_error ("raise", "omit", "return") – If raise, an underlying exception will be raised (converted to KeyError if the type is in self.missing_exceptions); if omit, keys with exception will simply not be included in the output; if “return”, all keys are included in the output, but the value will be bytes or an exception instance.

  • kwargs (passed to cat_file) –

Returns

  • dict of {path (contents} if there are multiple paths)

  • or the path has been otherwise expanded

cat_file(path, start=None, end=None, **kwargs)

Get the content of a file

Parameters
  • path (URL of file on this filesystems) –

  • start (int) – Bytes limits of the read. If negative, backwards from end, like usual python slices. Either can be None for start or end of file, respectively

  • end (int) – Bytes limits of the read. If negative, backwards from end, like usual python slices. Either can be None for start or end of file, respectively

  • kwargs (passed to open().) –

cat_ranges(paths, starts, ends, max_gap=None, on_error='return', **kwargs)
checksum(path)

Unique value for current version of file

If the checksum is the same from one moment to another, the contents are guaranteed to be the same. If the checksum changes, the contents might have changed.

This should normally be overridden; default will probably capture creation/modification timestamp (which would be good) or maybe access timestamp (which would be bad)

classmethod clear_instance_cache()

Clear the cache of filesystem instances.

Notes

Unless overridden by setting the cachable class attribute to False, the filesystem class stores a reference to newly created instances. This prevents Python’s normal rules around garbage collection from working, since the instances refcount will not drop to zero until clear_instance_cache is called.

static close_session(loop, session)
copy(path1, path2, recursive=False, maxdepth=None, on_error=None, **kwargs)

Copy within two locations in the filesystem

on_error“raise”, “ignore”

If raise, any not-found exceptions will be raised; if ignore any not-found exceptions will cause the path to be skipped; defaults to raise unless recursive is true, where the default is ignore

cp(path1, path2, **kwargs)

Alias of AbstractFileSystem.copy.

cp_file(path1, path2, **kwargs)
created(path)

Return the created timestamp of a file as a datetime.datetime

classmethod current()

Return the most recently instantiated FileSystem

If no instance has been created, then create one with defaults

delete(path, recursive=False, maxdepth=None)

Alias of AbstractFileSystem.rm.

disable_throttling = False
disk_usage(path, total=True, maxdepth=None, **kwargs)

Alias of AbstractFileSystem.du.

download(rpath, lpath, recursive=False, **kwargs)

Alias of AbstractFileSystem.get.

du(path, total=True, maxdepth=None, withdirs=False, **kwargs)

Space used by files and optionally directories within a path

Directory size does not include the size of its contents.

Parameters
  • path (str) –

  • total (bool) – Whether to sum all the file sizes

  • maxdepth (int or None) – Maximum number of directory levels to descend, None for unlimited.

  • withdirs (bool) – Whether to include directory paths in the output.

  • kwargs (passed to find) –

Returns

  • Dict of {path (size} if total=False, or int otherwise, where numbers)

  • refer to bytes used.

encode_url(url)
end_transaction()

Finish write transaction, non-context version

exists(path, **kwargs)

Is there a file at the given path

expand_path(path, recursive=False, maxdepth=None, **kwargs)

Turn one or more globs or directories into a list of all matching paths to files or directories.

kwargs are passed to glob or find, which may in turn call ls

find(path, maxdepth=None, withdirs=False, detail=False, **kwargs)

List all files below path.

Like posix find command without conditions

Parameters
  • path (str) –

  • maxdepth (int or None) – If not None, the maximum number of levels to descend

  • withdirs (bool) – Whether to include directory paths in the output. This is True when used by glob, but users usually only want files.

  • ls. (kwargs are passed to) –

static from_json(blob)

Recreate a filesystem instance from JSON representation

See .to_json() for the expected structure of the input

Parameters

blob (str) –

Return type

file system instance, not necessarily of this particular class.

property fsid

Persistent filesystem id that can be used to compare filesystems across sessions.

get(rpath, lpath, recursive=False, callback=<fsspec.callbacks.NoOpCallback object>, maxdepth=None, **kwargs)

Copy file(s) to local.

Copies a specific file or tree of files (if recursive=True). If lpath ends with a “/”, it will be assumed to be a directory, and target files will go within. Can submit a list of paths, which may be glob-patterns and will be expanded.

Calls get_file for each source.

get_file(rpath, lpath, callback=<fsspec.callbacks.NoOpCallback object>, outfile=None, **kwargs)

Copy single remote file to local

get_mapper(root='', check=False, create=False, missing_exceptions=None)

Create key/value store based on this file-system

Makes a MutableMapping interface to the FS at the given root path. See fsspec.mapping.FSMap for further details.

glob(path, maxdepth=None, **kwargs)

Find files by glob-matching.

If the path ends with ‘/’, only folders are returned.

We support "**", "?" and "[..]". We do not support ^ for pattern negation.

The maxdepth option is applied on the first ** found in the path.

Search path names that contain embedded characters special to this implementation of glob may not produce expected results; e.g., ‘foo/bar/starredfilename’.

kwargs are passed to ls.

head(path, size=1024)

Get the first size bytes from file

info(path, **kwargs)

Give details of entry at path

Returns a single dictionary, with exactly the same information as ls would with detail=True.

The default implementation should calls ls and could be overridden by a shortcut. kwargs are passed on to `ls().

Some file systems might not be able to measure the file’s size, in which case, the returned dict will include 'size': None.

Returns

  • dict with keys (name (full path in the FS), size (in bytes), type (file,)

  • directory, or something else) and other FS-specific keys.

invalidate_cache(path=None)

Discard any cached directory information

Parameters

path (string or None) – If None, clear all listings cached else listings at or under given path.

isdir(path)

Is this entry directory-like?

isfile(path)

Is this entry file-like?

lexists(path, **kwargs)

If there is a file at the given path (including broken links)

listdir(path, detail=True, **kwargs)

Alias of AbstractFileSystem.ls.

property loop
ls(url, detail=True, **kwargs)

List objects at path.

This should include subdirectories and files at that location. The difference between a file and a directory must be clear when details are requested.

The specific keys, or perhaps a FileInfo class, or similar, is TBD, but must be consistent across implementations. Must include:

  • full path to the entry (without protocol)

  • size of the entry, in bytes. If the value cannot be determined, will be None.

  • type of entry, “file”, “directory” or other

Additional information may be present, appropriate to the file-system, e.g., generation, checksum, etc.

May use refresh=True|False to allow use of self._ls_from_cache to check for a saved listing and avoid calling the backend. This would be common where listing may be expensive.

Parameters
  • path (str) –

  • detail (bool) – if True, gives a list of dictionaries, where each is the same as the result of info(path). If False, gives a list of paths (str).

  • kwargs (may have additional backend-specific options, such as version) – information

Returns

  • List of strings if detail is False, or list of directory information

  • dicts if detail is True.

makedir(path, create_parents=True, **kwargs)

Alias of AbstractFileSystem.mkdir.

makedirs(path, exist_ok=False)

Recursively make directories

Creates directory at path and any intervening required directories. Raises exception if, for instance, the path already exists but is a file.

Parameters
  • path (str) – leaf directory name

  • exist_ok (bool (False)) – If False, will error if the target already exists

mirror_sync_methods = True
mkdir(path, create_parents=True, **kwargs)

Create directory entry at path

For systems that don’t have true directories, may create an for this instance only and not touch the real filesystem

Parameters
  • path (str) – location

  • create_parents (bool) – if True, this is equivalent to makedirs

  • kwargs – may be permissions, etc.

mkdirs(path, exist_ok=False)

Alias of AbstractFileSystem.makedirs.

modified(path)

Return the modified timestamp of a file as a datetime.datetime

move(path1, path2, **kwargs)

Alias of AbstractFileSystem.mv.

mv(path1, path2, recursive=False, maxdepth=None, **kwargs)

Move file(s) from one location to another

open(path, mode='rb', block_size=None, cache_options=None, compression=None, **kwargs)

Return a file-like object from the filesystem

The resultant instance must function correctly in a context with block.

Parameters
  • path (str) – Target file

  • mode (str like 'rb', 'w') – See builtin open()

  • block_size (int) – Some indication of buffering - this is a value in bytes

  • cache_options (dict, optional) – Extra arguments to pass through to the cache.

  • compression (string or None) – If given, open file using compression codec. Can either be a compression name (a key in fsspec.compression.compr) or “infer” to guess the compression from the filename suffix.

  • encoding (passed on to TextIOWrapper for text mode) –

  • errors (passed on to TextIOWrapper for text mode) –

  • newline (passed on to TextIOWrapper for text mode) –

async open_async(path, mode='rb', size=None, **kwargs)
pipe(path, value=None, **kwargs)

Put value into path

(counterpart to cat)

Parameters
  • path (string or dict(str, bytes)) – If a string, a single remote location to put value bytes; if a dict, a mapping of {path: bytesvalue}.

  • value (bytes, optional) – If using a single path, these are the bytes to put there. Ignored if path is a dict

pipe_file(path, value, **kwargs)

Set the bytes of given file

protocol: ClassVar[str | tuple[str, ...]] = 'abstract'
put(lpath, rpath, recursive=False, callback=<fsspec.callbacks.NoOpCallback object>, maxdepth=None, **kwargs)

Copy file(s) from local.

Copies a specific file or tree of files (if recursive=True). If rpath ends with a “/”, it will be assumed to be a directory, and target files will go within.

Calls put_file for each source.

put_file(lpath, rpath, callback=<fsspec.callbacks.NoOpCallback object>, **kwargs)

Copy single file to remote

read_block(fn, offset, length, delimiter=None)

Read a block of bytes from

Starting at offset of the file, read length bytes. If delimiter is set then we ensure that the read starts and stops at delimiter boundaries that follow the locations offset and offset + length. If offset is zero then we start at zero. The bytestring returned WILL include the end delimiter string.

If offset+length is beyond the eof, reads to eof.

Parameters
  • fn (string) – Path to filename

  • offset (int) – Byte offset to start read

  • length (int) – Number of bytes to read. If None, read to end.

  • delimiter (bytes (optional)) – Ensure reading starts and stops at delimiter bytestring

Examples

>>> fs.read_block('data/file.csv', 0, 13)  
b'Alice, 100\nBo'
>>> fs.read_block('data/file.csv', 0, 13, delimiter=b'\n')  
b'Alice, 100\nBob, 200\n'

Use length=None to read to the end of the file. >>> fs.read_block(‘data/file.csv’, 0, None, delimiter=b’n’) # doctest: +SKIP b’Alice, 100nBob, 200nCharlie, 300’

See also

fsspec.utils.read_block()

read_bytes(path, start=None, end=None, **kwargs)

Alias of AbstractFileSystem.cat_file.

read_text(path, encoding=None, errors=None, newline=None, **kwargs)

Get the contents of the file as a string.

Parameters
  • path (str) – URL of file on this filesystems

  • encoding (same as open.) –

  • errors (same as open.) –

  • newline (same as open.) –

rename(path1, path2, **kwargs)

Alias of AbstractFileSystem.mv.

rm(path, recursive=False, maxdepth=None)

Delete files.

Parameters
  • path (str or list of str) – File(s) to delete.

  • recursive (bool) – If file(s) are directories, recursively delete contents and then also remove the directory

  • maxdepth (int or None) – Depth to pass to walk for finding files to delete, if recursive. If None, there will be no limit and infinite recursion may be possible.

rm_file(path)

Delete a file

rmdir(path)

Remove a directory, if empty

root_marker = ''
sep = '/'
async set_session()
sign(path, expiration=100, **kwargs)

Create a signed URL representing the given path

Some implementations allow temporary URLs to be generated, as a way of delegating credentials.

Parameters
  • path (str) – The path on the filesystem

  • expiration (int) – Number of seconds to enable the URL for (if supported)

Returns

URL – The signed URL

Return type

str

:raises NotImplementedError : if method is not implemented for a filesystem:

size(path)

Size in bytes of file

sizes(paths)

Size in bytes of each file in a list of paths

start_transaction()

Begin write transaction for deferring files, non-context version

stat(path, **kwargs)

Alias of AbstractFileSystem.info.

tail(path, size=1024)

Get the last size bytes from file

to_json()

JSON representation of this filesystem instance

Returns

str – protocol (text name of this class’s protocol, first one in case of multiple), args (positional args, usually empty), and all other kwargs as their own keys.

Return type

JSON structure with keys cls (the python location of this class),

touch(path, truncate=True, **kwargs)

Create empty file, or update timestamp

Parameters
  • path (str) – file location

  • truncate (bool) – If True, always set file size to 0; if False, update timestamp and leave file unchanged, if backend allows this

property transaction

A context within which files are committed together upon exit

Requires the file class to implement .commit() and .discard() for the normal and exception cases.

ukey(url)

Unique identifier; assume HTTP files are static, unchanging

unstrip_protocol(name)

Format FS-specific path to generic, including protocol

upload(lpath, rpath, recursive=False, **kwargs)

Alias of AbstractFileSystem.put.

walk(path, maxdepth=None, topdown=True, on_error='omit', **kwargs)

Return all files belows path

List all files, recursing into subdirectories; output is iterator-style, like os.walk(). For a simple list of files, find() is available.

When topdown is True, the caller can modify the dirnames list in-place (perhaps using del or slice assignment), and walk() will only recurse into the subdirectories whose names remain in dirnames; this can be used to prune the search, impose a specific order of visiting, or even to inform walk() about directories the caller creates or renames before it resumes walk() again. Modifying dirnames when topdown is False has no effect. (see os.walk)

Note that the “files” outputted will include anything that is not a directory, such as links.

Parameters
  • path (str) – Root to recurse into

  • maxdepth (int) – Maximum recursion depth. None means limitless, but not recommended on link-based file-systems.

  • topdown (bool (True)) – Whether to walk the directory tree from the top downwards or from the bottom upwards.

  • on_error ("omit", "raise", a collable) – if omit (default), path with exception will simply be empty; If raise, an underlying exception will be raised; if callable, it will be called with a single OSError instance as argument

  • kwargs (passed to ls) –

write_bytes(path, value, **kwargs)

Alias of AbstractFileSystem.pipe_file.

write_text(path, value, encoding=None, errors=None, newline=None, **kwargs)

Write the text to the given file.

An existing file will be overwritten.

Parameters
  • path (str) – URL of file on this filesystems

  • value (str) – Text to write.

  • encoding (same as open.) –

  • errors (same as open.) –

  • newline (same as open.) –

class euporie.core.path.HTTPPath(*args: str | PathLike, **kwargs: Any)

Bases: upath.implementations.http.HTTPPath

An HTTP path which caches content.

absolute() upath.core.PT

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.

property anchor

The concatenation of the drive and root, or ‘’.

as_posix()

Return the string representation of the path with forward (/) slashes.

as_uri()

Return the path as a ‘file’ URI.

chmod(mode, *, follow_symlinks: bool = True) None

Change the permissions of the path, like os.chmod().

cwd()

Return a new path pointing to the current working directory (as returned by os.getcwd()).

property drive

The drive prefix (letter or UNC path), if any.

exists() bool

Whether this path exists.

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

property fs: AbstractFileSystem
glob(pattern: str) Generator[PT, None, None]

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

group()

Return the group name of the file gid.

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.

home()

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

is_absolute() bool

True if the path is absolute (has both a root and, if applicable, a drive).

is_block_device() bool

Whether this path is a block device.

is_char_device() bool

Whether this path is a character device.

is_dir()

Whether this path is a directory.

is_fifo() bool

Whether this path is a FIFO.

is_file()

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount() bool

Check if this path is a POSIX mount point

is_relative_to(*other)

Return True if the path is relative to another path or False.

is_reserved()

Return True if the path contains one of the special names reserved by the system, if any.

is_socket() bool

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir() Generator[PT, None, None]

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

joinpath(*args)

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)

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

Make the target path a hard link pointing to this path.

Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.

Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.

lstat()

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)

Return True if this path matches the given pattern.

mkdir(mode: int = 511, parents: bool = False, exist_ok: bool = False) None

Create a new directory at this given path.

property name

The final path component, if any.

open(*args, **kwargs)

Open the file pointed by this path and return a file object, as the built-in open() function does.

owner()

Return the login name of the file owner.

property parent: upath.core.PT

The logical parent of the path.

property parents: upath.core._UPathParents

A sequence of this upath’s logical parents.

property parts

An object providing sequence-like access to the components in the filesystem path.

property path: str
read_bytes()

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None)

Open the file in text mode, read it, and close the file.

Return the path to which the symbolic link points.

relative_to(*other: str | os.PathLike) upath.core.PT

Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.

rename(target)

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)

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, follow_redirects: bool = True) upath.implementations.http.HTTPPath

Normalize the path and resolve redirects.

rglob(pattern: str) Generator[PT, None, None]

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

rmdir(recursive: bool = True) None

Add warning if directory not empty assert is_dir?

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()

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’]

Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.

touch(*args: int, truncate: bool = True, **kwargs) None

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

with_name(name: str) upath.core.PT

Return a new path with the file name changed.

with_stem(stem)

Return a new path with the stem changed.

with_suffix(suffix: str) upath.core.PT

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.

euporie.core.path.parse_path(path: str | PathLike, resolve: bool = True) Path

Parse and resolve a path.