hydra.file module
A model for file-system paths and metadata. Several types here are drawn from the POSIX <sys/stat.h> specification; see https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_stat.h.html.
- class hydra.file.FileExtension(value: T)
Bases:
Node[str]A file extension (without the dot), e.g. “json” or “py”.
- TYPE_ = Name(value='hydra.file.FileExtension')
- class hydra.file.FilePath(value: T)
Bases:
Node[str]A host file-system path; a POSIX “pathname” (XBD section 3.254), i.e. a string used to identify a file. Named FilePath rather than Pathname so that the kernel type is self-describing and distinct from Hydra’s other notions of paths.
- TYPE_ = Name(value='hydra.file.FilePath')
- class hydra.file.FileStatus(file_type: Annotated[FileType, 'st_mode (file type bits) / the type of the file'], size: Annotated[int, 'st_size / the size of the file in bytes. Well-defined for regular files and symbolic links; implementation-defined for other file types'], modification_time: Annotated[Timespec, 'st_mtim / the time of last data modification'], access_time: Annotated[object, 'st_atim / the time of last data access, if available. Optional, as it is unreliable or untracked on some filesystems and platforms (e.g. noatime mounts)'], status_change_time: Annotated[object, 'st_ctim / the time of last file status change, if available. Optional, as this POSIX-specific notion does not map onto all platforms'])
Bases:
objectMetadata about a file, based on the POSIX struct stat. Only the portable, cross-platform subset of struct stat is modeled here; the following Unix-specific fields are omitted for now: st_dev (device ID), st_ino (inode number), st_mode permission bits (only the file type bits are kept, as fileType), st_nlink (hard link count), st_uid (owner user ID), st_gid (owner group ID), st_rdev (device ID for special files), st_blksize (preferred I/O block size), and st_blocks (number of blocks allocated). See <sys/stat.h> (https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_stat.h.html).
- ACCESS_TIME = Name(value='accessTime')
- class Builder(_file_type: 'FileType' = None, _size: 'int' = None, _modification_time: 'hydra.time.Timespec' = None, _access_time: 'Optional[hydra.time.Timespec]' = None, _status_change_time: 'Optional[hydra.time.Timespec]' = None)
Bases:
object- access_time(access_time)
- build()
- file_type(file_type)
- modification_time(modification_time)
- size(size)
- status_change_time(status_change_time)
- FILE_TYPE = Name(value='fileType')
- MODIFICATION_TIME = Name(value='modificationTime')
- SIZE = Name(value='size')
- STATUS_CHANGE_TIME = Name(value='statusChangeTime')
- TYPE_ = Name(value='hydra.file.FileStatus')
- access_time: Annotated[object, 'st_atim / the time of last data access, if available. Optional, as it is unreliable or untracked on some filesystems and platforms (e.g. noatime mounts)']
- static builder()
- size: Annotated[int, 'st_size / the size of the file in bytes. Well-defined for regular files and symbolic links; implementation-defined for other file types']
- status_change_time: Annotated[object, 'st_ctim / the time of last file status change, if available. Optional, as this POSIX-specific notion does not map onto all platforms']
- with_access_time(access_time)
- with_file_type(file_type)
- with_modification_time(modification_time)
- with_size(size)
- with_status_change_time(status_change_time)
- class hydra.file.FileType(*values)
Bases:
EnumAn enumeration of POSIX file types, following the file type macros of <sys/stat.h>.
- BLOCK = Name(value='block')
a block special file (e.g. a disk device)
- Type:
S_IFBLK / block special
- CHARACTER = Name(value='character')
a character special file (e.g. a terminal device)
- Type:
S_IFCHR / character special
- DIRECTORY = Name(value='directory')
a directory
- Type:
S_IFDIR / directory
- FIFO = Name(value='fifo')
a named pipe (FIFO)
- Type:
S_IFIFO / FIFO special
- LINK = Name(value='link')
a symbolic link
- Type:
S_IFLNK / symbolic link
- REGULAR = Name(value='regular')
a regular file
- Type:
S_IFREG / regular
- SOCKET = Name(value='socket')
a socket
- Type:
S_IFSOCK / socket
- TYPE_ = Name(value='hydra.file.FileType')