dandi.misctypes
¶
Added in version 0.36.0.
Miscellaneous public classes
- class dandi.misctypes.BasePath(parts: tuple[str, ...])[source]¶
An abstract base class for path-like objects that can be traversed with the
/
operator à lapathlib.Path
(though, unlikepathlib.Path
instances, “dividing” by another non-string path is not allowed). All paths are treated as forward-slash-separated relative paths under an empty-name “root” path.- abstract iterdir() Iterator[P] [source]¶
Returns a generator of the paths under the instance, which must be a directory
- joinpath(*paths: str) P [source]¶
Combine the path with each name or relative path in
paths
using the/
operator
- property name: str¶
The basename of the path object. When the object represents the root of a path hierarchy, this is the empty string.
- abstract property parent: P¶
The parent path of the object. The parent of the root of a path hierarchy is itself.
- property parents: tuple[P, ...]¶
A tuple of the path’s ancestors, starting at the parent and going up to (and including) the root of the hierarchy
- parts: tuple[str, ...]¶
The path components of the object
- property root_path: P¶
The root of the path object’s hierarchy
- abstract property size: int¶
The size of the resource at the path
- property stem: str¶
The basename without its final file extension, if any
- property suffix: str¶
The final file extension of the basename, if any
- property suffixes: list[str]¶
A list of the basename’s file extensions
- dandi.misctypes.DUMMY_DANDI_ETAG = Digest(algorithm=<DigestType.dandi_etag: 'dandi:dandi-etag'>, value='dddddddddddddddddddddddddddddddd-1')¶
Placeholder digest used in some situations where a digest is required but not actually relevant and would be too expensive to calculate
- class dandi.misctypes.Digest(algorithm: DigestType, value: str)[source]¶
A computed digest for a file or directory
- algorithm: DigestType¶
The digest algorithm used
- asdict() dict[DigestType, str] [source]¶
Convert the instance to a single-item
dict
mapping the digest algorithm to the digest value
- classmethod dandi_etag(value: str) Digest [source]¶
Construct a
Digest
with the given value and aalgorithm
ofDigestType.dandi_etag
- classmethod dandi_zarr(value: str) Digest [source]¶
Construct a
Digest
with the given value and aalgorithm
ofDigestType.dandi_zarr_checksum
- value: str¶
The digest itself
- class dandi.misctypes.LocalReadableFile(filepath: str | Path)[source]¶
A concrete implementation of
Readable
for local files.Instances of this class are obtained by calling
LocalFileAsset.as_readable()
orDandisetMetadataFile.as_readable()
.- filepath¶
The path to a local file to read
- class dandi.misctypes.Readable[source]¶
Added in version 0.50.0.
An abstract base class representing a local or remote resource that can be opened & read like a file
- abstract get_filename() str [source]¶
Returns the base name of the resource, suitable for use as a file name
- class dandi.misctypes.RemoteReadableAsset(url: str, size: int, mtime: datetime | None, name: str)[source]¶
A concrete implementation of
Readable
for DANDI blob assets on a remote server. The fsspec library must be installed with thehttp
extra (e.g.,pip install "fsspec[http]"
) in order foropen()
to be usable.Instances of this class are obtained by calling
BaseRemoteBlobAsset.as_readable()
.- get_mtime() datetime | None [source]¶
Returns the time at which the resource’s contents were last modified, if it can be determined
- url: str¶
The URL that data is read from