Utilities API
pathlib_next.utils.glob
full_match(segments, pattern, case_sensitive)
Match segments against a glob pattern that may contain "**"
components matching zero or more segments (pathlib 3.13's
PurePath.full_match semantics).
Source code in src/pathlib_next/utils/glob.py
31 32 33 34 35 36 37 | |
glob(path, *, dironly=False, root_dir=None, recursive=False, include_hidden=False, case_sensitive=None)
Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns.
If recursive is true, the pattern '**' will match any files and zero or more directories and subdirectories.
Source code in src/pathlib_next/utils/glob.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
pathlib_next.utils.stat
FileStat(st_mode=None, st_size=0, st_mtime=0, is_dir=False)
Bases: FileStatLike
Concrete, slotted FileStatLike for backends without a real
os.stat_result (e.g. MemPath, HttpPath). from_path() builds one
from any object with a stat() method, or passes a FileStat through
unchanged.
Source code in src/pathlib_next/utils/stat.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
from_stat(stat)
classmethod
Copy any stat-like object's (os.stat_result, paramiko's
SFTPAttributes, ...) recognized fields into a fresh FileStat,
so downstream code (e.g. .is_dir()) can rely on a uniform type.
Passes an already-FileStat through unchanged.
Source code in src/pathlib_next/utils/stat.py
81 82 83 84 85 86 87 88 89 90 91 92 | |
is_block_device()
Whether this path is a block device.
Source code in src/pathlib_next/utils/stat.py
121 122 123 124 125 | |
is_char_device()
Whether this path is a character device.
Source code in src/pathlib_next/utils/stat.py
127 128 129 130 131 | |
is_dir()
Whether this path is a directory.
Source code in src/pathlib_next/utils/stat.py
102 103 104 105 106 | |
is_fifo()
Whether this path is a FIFO.
Source code in src/pathlib_next/utils/stat.py
133 134 135 136 137 | |
is_file()
Whether this path is a regular file (also True for symlinks pointing to regular files).
Source code in src/pathlib_next/utils/stat.py
108 109 110 111 112 113 | |
is_socket()
Whether this path is a socket.
Source code in src/pathlib_next/utils/stat.py
139 140 141 142 143 | |
is_symlink()
Whether this path is a symbolic link.
Source code in src/pathlib_next/utils/stat.py
115 116 117 118 119 | |
pathlib_next.utils.sync
PathSyncer(checksum=None, /, remove_missing=False, follow_symlinks=True, hook=None, ignore_error=False)
Bases: object
One-way checksum-driven tree sync: copies/creates in target
whatever differs from source (by checksum), optionally removing
files in target that are missing from source. Works across any two
Path implementations (e.g. MemPath -> LocalPath, or between two
UriPath schemes) -- see sync().
Source code in src/pathlib_next/utils/sync.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
SyncEvent
Bases: Enum
Events PathSyncer.hook() fires during a sync, for progress/logging
callbacks.
pathlib_next.utils
LRU(func, maxsize=128)
Bases: Generic[K, V]
Thread-safe memoizing LRU cache over a function, callable like the
function itself; invalidate(*args) evicts and recomputes an entry.
Source code in src/pathlib_next/utils/__init__.py
41 42 43 44 45 | |