Archives: zip:, tar:, archive:
archive+zip: and archive+tar: are second scheme names of ZipURIPath and
TarURIPath (they pin the format, which archive: detects); ArchiveZipURIPath and
ArchiveTarURIPath stay importable as aliases of those two classes.
uripath.schemes.ArchiveURIPath(*uris, **options)
Bases: DelegatingURIPath
Common base for zip:/tar:/archive: archive paths:
<scheme>:<archive-uri>!/<inner-path> (Java-style separator; the
<archive-uri> half is itself any absolute URI with an explicit scheme
-- file:, http:, sftp:, ftp:, ... -- so archives are readable
straight off any existing backend). segments/name/parent/glob/
... all operate on the inner path; the outer archive handle is the
backend, propagated through the normal backend machinery to every path
derived from this one, and the members are read and written by a
pathapi.archive.ArchivePath (ZipPath or TarPath once the format
is known) on that handle.
Also registered directly as the archive: catch-all scheme (see
__SCHEMES below): zip:/tar: (via ZipURIPath/TarURIPath, which just
pin _core_cls) fix the format; plain archive: leaves it undecided
and settles it on first use. Writes are gated on the handle being
writable, which only a zip archive that is a local file: ever is -- so a
tar-backed instance, whether reached via tar: or auto-detected via
archive:, correctly raises NotImplementedError on any write attempt
rather than silently misbehaving.
Source code in src/uripath/_uri.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__SCHEMES = ('archive',)
class-attribute
instance-attribute
__slots__ = ()
class-attribute
instance-attribute
backend
property
__new__(*args, **kwargs)
Source code in src/uripath/schemes/_archive.py
162 163 164 165 166 167 | |
as_uri(sanitize=False)
Source code in src/uripath/schemes/_archive.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
batch()
A context manager that holds every change made to this archive
while it is open and writes them in one replacement of the archive
file when the outermost block ends without an exception; an exception
leaves the archive as it was. Inside it every path of the archive
reads the held changes, and the file is not touched until the block
ends. A block inside another joins it. NotImplementedError when the
archive cannot be written.
Source code in src/uripath/schemes/_archive.py
180 181 182 183 184 185 186 187 188 189 | |
readlink()
The text a link member stores, as a LinkTarget (OSError(EINVAL)
when this member is not a link). Links on the way to it are followed.
Source code in src/uripath/schemes/_archive.py
191 192 193 194 195 | |
refresh()
Forgets what is held of the archive's outer file, so the next use reads it again. A non-local archive is read once and kept while any path to it lives, so this is how a later change at its source is seen; a local one is checked against the file on every use. Every path to the same archive shares the refresh.
Source code in src/uripath/schemes/_archive.py
172 173 174 175 176 177 178 | |
rename(target)
Source code in src/uripath/schemes/_archive.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
rm(recursive=False, missing_ok=False, ignore_error=False, *, follow_symlinks=False, follow_binds=False)
Source code in src/uripath/schemes/_archive.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
uripath.schemes.ZipURIPath(*uris, **options)
Bases: ArchiveURIPath
zip: scheme (archive+zip: is a second name for it). Read/write: write support (new entries, overwriting
existing entries, unlink/rmdir/rename) works when the outer
archive is a local file: URI; every other outer scheme is read-only
(fetched fully into memory first). Every mutation replaces the archive
atomically (temp file + os.replace), so the result is a new file: other
hard links keep the old content, and an archive the caller may not write
is refused first. A new entry is appended, deflated, to a byte copy of the
archive (nothing recompressed); overwriting/deleting/renaming an existing
entry rewrites the whole archive, since the standard library's zip module has no in-place
entry mutation, keeping every other entry's metadata and compression method.
The members are read and written by a pathapi.archive.ZipPath.
Source code in src/uripath/_uri.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__SCHEMES = ('zip', 'archive+zip')
class-attribute
instance-attribute
__slots__ = ()
class-attribute
instance-attribute
uripath.schemes.TarURIPath(*uris, **options)
Bases: ArchiveURIPath
tar: scheme (also handles .tar.gz/.tar.bz2/.tar.xz via
the standard library's auto-detected "r:*" mode). Read-only. Members stored with a
./ prefix are addressed without it. archive+tar: is the same scheme
under a second name. The members are read by a
pathapi.archive.TarPath.
Source code in src/uripath/_uri.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__SCHEMES = ('tar', 'archive+tar')
class-attribute
instance-attribute
__slots__ = ()
class-attribute
instance-attribute
uripath.schemes.MEMBER_SPOOL_BYTES is the size above which the content of an
archive member read into memory is spooled to a temporary file; assign a
different number to change it.