angelos.archive7.fs¶
File system.
-
class
angelos.archive7.fs.
AbstractFilesystemSession
¶ Bases:
abc.ABC
Abstract class for a file system session. (current directory support).
-
abstract
chdir
(path)¶
-
abstract
chroot
(path)¶
-
abstract
fchdir
(fd)¶
-
abstract
getcwd
()¶
-
abstract
getcwdb
()¶
-
abstract
-
class
angelos.archive7.fs.
AbstractVirtualFilesystem
¶ Bases:
abc.ABC
Abstract class for a virtual file system.
-
abstract
unmount
()¶
-
abstract
-
class
angelos.archive7.fs.
Delete
(value)¶ Bases:
enum.IntEnum
Delete mode flags.
-
ERASE
= 3¶
-
HARD
= 2¶
-
SOFT
= 1¶
-
-
class
angelos.archive7.fs.
EntryRecord
(type: bytes = b'f', identity: uuid.UUID = UUID('84217ffc-9110-4392-80a0-2d64a7652c42'), parent: uuid.UUID = UUID('00000000-0000-0000-0000-000000000000'), owner: uuid.UUID = UUID('00000000-0000-0000-0000-000000000000'), stream: uuid.UUID = UUID('00000000-0000-0000-0000-000000000000'), created: datetime.datetime = datetime.datetime(1970, 1, 1, 1, 0), modified: datetime.datetime = datetime.datetime(1970, 1, 1, 1, 0), length: int = None, deleted: bool = False, name: Union[bytes, bytearray] = None, user: Union[bytes, bytearray] = None, group: Union[bytes, bytearray] = None, perms: int = 493)¶ Bases:
object
Header for the Archive 7 format.
-
COMP_BZIP2
= 3¶
-
COMP_GZIP
= 2¶
-
COMP_NONE
= 0¶
-
COMP_ZIP
= 1¶
-
FORMAT
= '!c16s16s16s16sqqQ?256s32s16sH'¶
-
created
¶
-
deleted
¶
-
static
dir
(name: unicode, parent: uuid.UUID = None, owner: uuid.UUID = None, created: datetime.datetime = None, modified: datetime.datetime = None, user: unicode = None, group: unicode = None, perms: int = None) → EntryRecord¶
-
static
err
(identity: uuid.UUID, parent: uuid.UUID) → angelos.archive7.fs.EntryRecord¶ Generate entry for file link.
-
static
file
(name: unicode, stream: uuid.UUID, identity: uuid.UUID = None, parent: uuid.UUID = None, owner: uuid.UUID = None, created: datetime.datetime = None, modified: datetime.datetime = None, length: int = None, user: unicode = None, group: unicode = None, perms: int = None) → EntryRecord¶ Entry header for file.
-
group
¶
-
id
¶
-
length
¶
-
static
link
(name: unicode, link: uuid.UUID, parent: uuid.UUID = None, created: datetime.datetime = None, modified: datetime.datetime = None, user: unicode = None, group: unicode = None, perms: unicode = None) → EntryRecord¶ Generate entry for file link.
-
static
meta_unpack
(data: Union[bytes, bytearray]) → angelos.archive7.fs.EntryRecord¶
-
modified
¶
-
name
¶
-
owner
¶
-
parent
¶
-
perms
¶
-
stream
¶
-
type
¶
-
user
¶
-
-
class
angelos.archive7.fs.
EntryRegistry
(manager: DynamicMultiStreamManager)¶ Bases:
angelos.archive7.streams.Registry
Registry for all file, link and directory entries.
-
class
angelos.archive7.fs.
FileObject
(identity: uuid.UUID, stream: angelos.archive7.streams.DataStream, filename: unicode, mode: unicode = 'r')¶ Bases:
angelos.archive7.streams.VirtualFileObject
File object that is FileIO compliant.
-
fileno
() → uuid.UUID¶ File object entry UUID.
- Returns (uuid.UUID):
File UUID number
-
-
class
angelos.archive7.fs.
FileSystemStreamManager
(filename: pathlib.Path, secret: bytes)¶ Bases:
angelos.archive7.streams.DynamicMultiStreamManager
Stream management with all necessary registries for a filesystem and entry management.
-
SPECIAL_STREAM_COUNT
= 5¶
-
STREAM_ENTRIES
= 2¶
-
STREAM_LISTINGS
= 4¶
-
STREAM_PATHS
= 3¶
-
change_name
(identity: uuid.UUID, name: unicode)¶ Change name of an entry.
- Parameters
identity (uuid.UUID) – Entry UUID number
name (str) – New name to change to
-
change_parent
(identity: uuid.UUID, parent: uuid.UUID)¶ Change parent of an entry i.e. changing directory.
- Parameters
identity (uuid.UUID) – Entry UUID number
parent (uuid.UUID) – New parent UUID number
-
create_entry
(type_: bytes, name: unicode, parent: uuid.UUID = UUID('00000000-0000-0000-0000-000000000000'), **kwargs) → uuid.UUID¶ Create a new entry: file, directory or link.
- Parameters
type (bytes) – Type of entry
name (str) – Entry name
parent (uuid.UUID) – Parent entry UUID number
**kwargs – The rest of the entry fields
- Returns (uuid.UUID):
Entry UUID number
-
delete_entry
(identity: uuid.UUID, delete: int)¶ Delete entry according to level.
- Parameters
identity (uuid.UUID) – Entry UUID number
delete (int) – Delete level
-
open
(identity: uuid.UUID, mode: unicode = 'r') → angelos.archive7.fs.FileObject¶ Open a file stream as a file object.
- Parameters
identity (uuid.UUID) – File entry UUID number
mode (str) – File mode
- Returns (VirtualFileObject):
The opened file object
-
release
(fd: angelos.archive7.fs.FileObject)¶ Release a FileObject on close.
Never call this method from outside a FileObject.
- Parameters
fd (FileObject) – Open file object
-
resolve_path
(filename: pathlib.PurePosixPath, follow_link: bool = False) → uuid.UUID¶ Resolve a path by walking it.
- Parameters
filename (PurePath) – Path to resolve
follow_link (bool) – Whether to follow links
- Returns (uuid.UUID):
UUID of the deepest file or directory
-
search_entry
(identity: uuid.UUID) → angelos.archive7.fs.EntryRecord¶
-
traverse_hierarchy
(directory: uuid.UUID) → Iterator¶ Iterator that traverses the hierarchy.
Iterates over the listing of a directory and traverses down each directory. This iterator uses the listings to iterate over a directory, then yealds each entry.
- Parameters
directory (uuid.UUID) – Directory entry UUID number
- Returns (Iterator):
Iterator that traverses the hierarchy
-
update_entry
(identity: uuid.UUID, owner: uuid.UUID = None, modified: datetime.datetime = None, length: int = None, deleted: bool = None, user: unicode = None, group: unicode = None, perms: int = None)¶ Update certain fields in a entry.
- Parameters
identity (uuid.UUID) – Entry UUID number
owner (uuid.UUID) – Entry owner UUID number
modified (datetime.datetime) – New modified datetime
length (int) – Length of data
deleted (bool) – Deleted or not
user (str) – Unix user name
group (str) – Unix group name
perms (int) – Unix permissions
-
-
class
angelos.archive7.fs.
FilesystemMixin
¶ Bases:
abc.ABC
Mixin for all essential function calls for a file system.
-
abstract
access
(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)¶
-
abstract
chflags
(path, flags, *, follow_symlinks=True)¶
-
abstract
chmod
(path, mode, *, dir_fd=None, follow_symlinks=True)¶
-
abstract
chown
(path, uid, gid, *, dir_fd=None, follow_symlinks=True)¶
-
abstract
fwalk
(top='.', topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=None)¶
-
abstract
lchflags
(path, flags)¶
-
abstract
lchmod
(path, mode)¶
-
abstract
lchown
(path, uid, gid)¶
-
abstract
link
(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)¶
-
abstract
listdir
(path='.')¶
-
abstract
lstat
(path, *, dir_fd=None)¶
-
abstract
makedirs
(name, mode=511, exist_ok=False)¶
-
abstract
mkdir
(path, mode=511, *, dir_fd=None)¶
-
abstract
mkfifo
(path, mode=438, *, dir_fd=None)¶
-
abstract
readlink
(path, *, dir_fd=None)¶
-
abstract
remove
(path, *, dir_fd=None)¶
-
abstract
removedirs
(name)¶
-
abstract
rename
(src, dst, *, src_dir_fd=None, dst_dir_fd=None)¶
-
abstract
renames
(old, new)¶
-
abstract
replace
(src, dst, *, src_dir_fd=None, dst_dir_fd=None)¶
-
abstract
rmdir
(path, *, dir_fd=None)¶
-
abstract
scandir
(path='.')¶
-
abstract
stat
(path, *, dir_fd=None, follow_symlinks=True)¶
-
abstract
symlink
(src, dst, target_is_directory=False, *, dir_fd=None)¶
-
abstract
sync
()¶
-
abstract
time
(path, times=None, *, ns, dir_fd=None, follow_symlinks=True)¶
-
abstract
truncate
(path, length)¶
-
abstract
unlink
(path, *, dir_fd=None)¶
-
abstract
walk
(top, topdown=True, onerror=None, followlinks=False)¶
-
abstract
-
class
angelos.archive7.fs.
HierarchyTraverser
(identity: uuid.UUID, entries: angelos.archive7.fs.EntryRegistry, paths: angelos.archive7.fs.PathRegistry, listings: angelos.archive7.fs.ListingRegistry)¶ Bases:
collections.abc.Iterable
Traverse the file system hierarchy at a defined starting point.
-
property
path
¶ Current path.
-
property
-
exception
angelos.archive7.fs.
InvalidPath
¶ Bases:
RuntimeWarning
Failed to resolve path.
-
class
angelos.archive7.fs.
ListingRecord
(identity: uuid.UUID)¶ Bases:
object
Record of directory listing.
-
FORMAT
= '!16s'¶
-
static
meta_unpack
(data: Union[bytes, bytearray]) → angelos.archive7.fs.ListingRecord¶
-
-
class
angelos.archive7.fs.
ListingRegistry
(manager: DynamicMultiStreamManager)¶ Bases:
angelos.archive7.streams.Registry
Registry for directory listings.
-
class
angelos.archive7.fs.
PathRecord
(type_: bytes, identity: uuid.UUID)¶ Bases:
object
Record for parent id and entry name.
-
FORMAT
= '!c16s'¶
-
id
¶
-
static
meta_unpack
(data: Union[bytes, bytearray]) → angelos.archive7.fs.PathRecord¶
-
static
path
(type_: bytes, identity: uuid.UUID) → angelos.archive7.fs.PathRecord¶ Entry header for file.
-
type
¶
-
-
class
angelos.archive7.fs.
PathRegistry
(manager: DynamicMultiStreamManager)¶ Bases:
angelos.archive7.streams.Registry
Registry for directory traversal and entry uniqueness.
-
exception
angelos.archive7.fs.
VirtualFSError
¶ Bases:
RuntimeError
Errors from virtual file system.
-
ENTRY_DELETED
= ('Record is considered deleted.', 112)¶
-
FILES_IN_DIR
= ("Can't delete directory because of files", 106)¶
-
FILE_ALREADY_OPEN
= ('File already open.', 110)¶
-
IDENTITY_NO_ENTRY
= ('No entry for identity.', 108)¶
-
LINK_TARGET_ERROR
= ("Target of link doesn't exist", 102)¶
-
LINK_TO_LINK
= ('Target of a link must be file or directory, not another link', 103)¶
-
NOT_ABSOLUTE_PATH
= ('Must be an absolute path.', 100)¶
-
NOT_A_DIR
= ('Is not a directory', 109)¶
-
NOT_A_FILE
= ('Record not of type file.', 111)¶
-
PATH_EXISTS_ALREADY
= ('Key already exists in paths', 101)¶
-
PATH_EXISTS_NOT
= ("Entry doesn't exist", 105)¶
-
UNKNOWN_DELETE_LEVEL
= ('Delete level unknown', 107)¶
-
UNKNOWN_ENTRY_TYPE
= ('Entry type is unknown', 104)¶
-