|
|
@ -54,6 +54,10 @@ class NodeAny(NodeMixin): # type: ignore
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
|
|
|
|
"""can node contains sub"""
|
|
|
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
|
|
def _to_str(self) -> str:
|
|
|
|
def _to_str(self) -> str:
|
|
|
|
ret = str(self.__class__) + ": " + str(self.__dict__)
|
|
|
|
ret = str(self.__class__) + ": " + str(self.__dict__)
|
|
|
|
if self.children:
|
|
|
|
if self.children:
|
|
|
@ -65,18 +69,27 @@ class NodeAny(NodeMixin): # type: ignore
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def get_fullpath(self) -> str:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""return full path to this node"""
|
|
|
|
raise NotImplementedError
|
|
|
|
path = self.name
|
|
|
|
|
|
|
|
if self.parent:
|
|
|
|
|
|
|
|
typcast_node(self.parent)
|
|
|
|
|
|
|
|
ppath = self.parent.get_fullpath()
|
|
|
|
|
|
|
|
path = os.path.join(ppath, path)
|
|
|
|
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
totsize: int = self.nodesize
|
|
|
|
|
|
|
|
for node in self.children:
|
|
|
|
|
|
|
|
typcast_node(node)
|
|
|
|
|
|
|
|
totsize += node.get_rec_size()
|
|
|
|
|
|
|
|
return totsize
|
|
|
|
|
|
|
|
|
|
|
|
def get_storage_node(self) -> NodeMixin:
|
|
|
|
def get_storage_node(self) -> NodeMixin:
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def flagged(self) -> bool:
|
|
|
|
def flagged(self) -> bool:
|
|
|
|
"""is flagged"""
|
|
|
|
"""is flagged"""
|
|
|
|
if not hasattr(self, '_flagged'):
|
|
|
|
if not hasattr(self, '_flagged'):
|
|
|
@ -107,13 +120,22 @@ class NodeTop(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def get_fullpath(self) -> str:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""return full path to this node"""
|
|
|
|
return ''
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
|
|
|
|
"""can node contains sub"""
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
"""
|
|
|
|
return 0
|
|
|
|
recursively traverse tree and return size
|
|
|
|
|
|
|
|
also ensure to update the size on the way
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
size = super().get_rec_size()
|
|
|
|
|
|
|
|
self.nodesize = size
|
|
|
|
|
|
|
|
return size
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
@ -140,22 +162,14 @@ class NodeFile(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""can node contains sub"""
|
|
|
|
typcast_node(self.parent)
|
|
|
|
return False
|
|
|
|
path = self.parent.get_parent_hierarchy()
|
|
|
|
|
|
|
|
if path:
|
|
|
|
|
|
|
|
return os.sep.join([path, self.name])
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
return self.nodesize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
|
|
|
|
|
|
|
|
@ -179,26 +193,23 @@ class NodeDir(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""can node contains sub"""
|
|
|
|
typcast_node(self.parent)
|
|
|
|
return True
|
|
|
|
path = self.parent.get_parent_hierarchy()
|
|
|
|
|
|
|
|
if path:
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
return os.sep.join([path, self.name])
|
|
|
|
"""
|
|
|
|
return ''
|
|
|
|
recursively traverse tree and return size
|
|
|
|
|
|
|
|
also ensure to update the size on the way
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
size = super().get_rec_size()
|
|
|
|
|
|
|
|
self.nodesize = size
|
|
|
|
|
|
|
|
return size
|
|
|
|
|
|
|
|
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
totsize: int = 0
|
|
|
|
|
|
|
|
for node in self.children:
|
|
|
|
|
|
|
|
typcast_node(node)
|
|
|
|
|
|
|
|
totsize += node.get_rec_size()
|
|
|
|
|
|
|
|
return totsize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
|
|
|
|
|
|
|
|
@ -224,22 +235,14 @@ class NodeArchived(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""can node contains sub"""
|
|
|
|
typcast_node(self.parent)
|
|
|
|
return False
|
|
|
|
path = self.parent.get_parent_hierarchy()
|
|
|
|
|
|
|
|
if path:
|
|
|
|
|
|
|
|
return os.sep.join([path, self.name])
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
return cast(NodeStorage, self.ancestors[1])
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
return self.nodesize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
|
|
|
|
|
|
|
|
@ -269,22 +272,23 @@ class NodeStorage(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""can node contains sub"""
|
|
|
|
return ''
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
recursively traverse tree and return size
|
|
|
|
|
|
|
|
also ensure to update the size on the way
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
size = super().get_rec_size()
|
|
|
|
|
|
|
|
self.nodesize = size
|
|
|
|
|
|
|
|
return size
|
|
|
|
|
|
|
|
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
def get_storage_node(self) -> NodeAny:
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
"""recursively traverse up to find storage"""
|
|
|
|
return self
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
|
|
|
|
totsize: int = 0
|
|
|
|
|
|
|
|
for node in self.children:
|
|
|
|
|
|
|
|
typcast_node(node)
|
|
|
|
|
|
|
|
totsize += node.get_rec_size()
|
|
|
|
|
|
|
|
return totsize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return self._to_str()
|
|
|
|
return self._to_str()
|
|
|
|
|
|
|
|
|
|
|
@ -306,13 +310,9 @@ class NodeMeta(NodeAny):
|
|
|
|
if children:
|
|
|
|
if children:
|
|
|
|
self.children = children
|
|
|
|
self.children = children
|
|
|
|
|
|
|
|
|
|
|
|
def get_parent_hierarchy(self) -> str:
|
|
|
|
def may_have_children(self) -> bool:
|
|
|
|
"""get all parents recursively"""
|
|
|
|
"""can node contains sub"""
|
|
|
|
typcast_node(self.parent)
|
|
|
|
return False
|
|
|
|
path = self.parent.get_parent_hierarchy()
|
|
|
|
|
|
|
|
if path:
|
|
|
|
|
|
|
|
return os.sep.join([path, self.name])
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
def get_rec_size(self) -> int:
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|
"""recursively traverse tree and return size"""
|
|
|
|