-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathfile.py
More file actions
22 lines (17 loc) · 640 Bytes
/
Copy pathfile.py
File metadata and controls
22 lines (17 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"A File class"
from interface_component import IComponent
class File(IComponent):
"The File Class. The files are leaves"
def __init__(self, name):
self.name = name
def dir(self, indent):
parent_id = (id(self.reference_to_parent)
if self.reference_to_parent is not None else None)
print(
f"{indent}<FILE> {self.name}\t\t"
f"id:{id(self)}\tParent:\t{parent_id}"
)
def detach(self):
"Detaching this file (leaf) from its parent composite"
if self.reference_to_parent is not None:
self.reference_to_parent.delete(self)