Filesystem Module

Contains VFS(Virtual File System) related objects. Filesystem is loaded from an initial template(resources/fs_template.pkl) in Pickle format. If you wish to create your own template please take a look at the map_filesystem.py script under resources directory.

class stage_props.filesystem.VirtualFileSystem(artifacts_store_root: str, default_username: str, filesystem_template_path: str = '/home/omri/PycharmProjects/MoP/stage_props/../resources/fs_template.pkl', lazy_load: bool = True)
exists(path)

Check if a directory exists by path

is_dir(path) → bool

Check if a path is an existing directory

is_file(path) → bool

Check if a path is an existing file

listdir(path)

List directory by path

mkdir(path: str) → stage_props.filesystem.VirtualDirectory

Create a new directory

open(file_path: str) → stage_props.filesystem.VirtualFile

Open a file by path for r/w operations

class stage_props.filesystem.VirtualFile(name, physical_path, default_data=b'', default_size: int = 0)
append(data)

Append data to the end of the file

close()

Close file object. Automatically flush any written data to disk

flush()

Flush any written data to disk

read(n=-1)

Read n bytes from file

seek(pos)

Set the file’s pointer position

property sha256

Calculate SHA256 of file’s data

property size

Get the current size of the file

write(data)

Write data to file

class stage_props.filesystem.VirtualDirectory(name, physical_path, parent_directory=None)
create_directory(name: str) → stage_props.filesystem.VirtualDirectory

Create new child directory

create_file(name, default_size: int = 0) → stage_props.filesystem.VirtualFile

Create new file under this directory

exists(name)

Check if file or directory are childs of current directory

is_dir(name)

Check if directory is a child of current directory

is_file(name)

Check if file is a child of current directory

open_dir(name)

Open existing sub-directory

open_file(name)

Open existing file under current directory