Describe state
This commit is contained in:
@@ -18,11 +18,16 @@ class FileSystem(SimComponent):
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Get the current state of the FileSystem as a dict.
|
||||
Produce a dictionary describing the current state of this object.
|
||||
|
||||
:return: A dict containing the current state of the FileSystemFile.
|
||||
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
||||
|
||||
:return: Current state of this object and child objects.
|
||||
:rtype: Dict
|
||||
"""
|
||||
pass
|
||||
state = super().describe_state()
|
||||
state.update({"folders": {uuid: folder for uuid, folder in self.folders.items()}})
|
||||
return state
|
||||
|
||||
def get_folders(self) -> Dict:
|
||||
"""Returns the list of folders."""
|
||||
|
||||
@@ -38,8 +38,16 @@ class FileSystemFile(FileSystemItem):
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Get the current state of the FileSystemFile as a dict.
|
||||
Produce a dictionary describing the current state of this object.
|
||||
|
||||
:return: A dict containing the current state of the FileSystemFile.
|
||||
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
||||
|
||||
:return: Current state of this object and child objects.
|
||||
:rtype: Dict
|
||||
"""
|
||||
pass
|
||||
return {
|
||||
"uuid": self.uuid,
|
||||
"name": self.name,
|
||||
"size": self.size,
|
||||
"file_type": self.file_type,
|
||||
}
|
||||
|
||||
@@ -16,6 +16,23 @@ class FileSystemFolder(FileSystemItem):
|
||||
is_quarantined: bool = False
|
||||
"""Flag that marks the folder as quarantined if true."""
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Produce a dictionary describing the current state of this object.
|
||||
|
||||
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
||||
|
||||
:return: Current state of this object and child objects.
|
||||
:rtype: Dict
|
||||
"""
|
||||
return {
|
||||
"uuid": self.uuid,
|
||||
"name": self.name,
|
||||
"size": self.size,
|
||||
"files": {uuid: file for uuid, file in self.files.items()},
|
||||
"is_quarantined": self.is_quarantined,
|
||||
}
|
||||
|
||||
def get_file_by_id(self, file_id: str) -> FileSystemFile:
|
||||
"""Return a FileSystemFile with the matching id."""
|
||||
return self.files.get(file_id)
|
||||
@@ -67,11 +84,3 @@ class FileSystemFolder(FileSystemItem):
|
||||
def quarantine_status(self) -> bool:
|
||||
"""Returns true if the folder is being quarantined."""
|
||||
return self.is_quarantined
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Get the current state of the FileSystemFolder as a dict.
|
||||
|
||||
:return: A dict containing the current state of the FileSystemFile.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -13,5 +13,19 @@ class FileSystemItem(SimComponent):
|
||||
"""The size the item takes up on disk."""
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""Returns the state of the FileSystemItem."""
|
||||
pass
|
||||
"""
|
||||
Produce a dictionary describing the current state of this object.
|
||||
|
||||
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
||||
|
||||
:return: Current state of this object and child objects.
|
||||
:rtype: Dict
|
||||
"""
|
||||
state = super().describe_state()
|
||||
state.update(
|
||||
{
|
||||
"name": self.name,
|
||||
"size": self.size,
|
||||
}
|
||||
)
|
||||
return state
|
||||
|
||||
Reference in New Issue
Block a user