-
Notifications
You must be signed in to change notification settings - Fork 1
/
FSfolder.py
67 lines (50 loc) · 1.59 KB
/
FSfolder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from FSelement import Element
import datetime
class Folder(Element):
root = None
def __init__(self, name, parent):
if parent == None:
if Folder.root == None:
Folder.root = self
parent = self
else: raise Exception()
self.__content = [];
Element.__init__(self, name, parent)
def drawTree():
print('Baumansicht'.center(80));
print(''.ljust(80, '='))
Folder.root.drawFolders(0)
def drawFolders(self, level):
space = "+"
for i in range(0, level):
space = "--" + space
print(space, self.getName())
for x in self.__content:
if isinstance(x, Folder):
x.drawFolders(level+1)
def getSize(self):
self.__size = 0
for element in self.__content:
self.__size += element.getSize()
return self.__size
def addElement(self, e):
self.__content.append(e)
e.__parent = self
def getChangeDate(self):
last = self.__changeDate
for x in self.__content:
changeDate = x.getChangeDate();
if changeDate > last:
last = changeDate
return last
# def printInfo(self):
# print (self.getName().ljust(20), str(self.getSize()).ljust(20), self.getType().ljust(14), str(self.getChangeDate()).ljust(26), sep="")
def listView(self):
print('Detailansicht'.center(80));
print(''.ljust(80, '='))
print("Dateiname".ljust(20), "Größe".ljust(20), "Typ".ljust(14), "Änderungsdatum".ljust(26), sep="")
print("".ljust(80, '='))
for x in self.__content:
x.printInfo()
def getType(self):
return "Folder"