-
Notifications
You must be signed in to change notification settings - Fork 0
/
objects.py
127 lines (101 loc) · 3.96 KB
/
objects.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Class for storing info about a Flipnote Studio (DSi) User
class StudioUser:
def __init__(self, studioIdIn):
self.id = studioIdIn
self.names = [] # For storing any name variations a user has
self.namesCount = [] # Stores the number of times a given name occurs
self.namesCommon = [] # Stores the most frequently occuring name or names
self.recalcCommon = False
self.flipnotes = [] # Stores the filenames (on disk) of this user's flipnotes
def getId(self):
return self.id
def getName(self, index):
return self.names[index]
def getNameUsage(self, index):
return self.namesCount[index]
def getTotalNames(self):
return len(self.names)
def getCommonNames(self):
if (self.recalcCommon):
self.recalcCommon = False
currentHigh = self.namesCount[0]
self.namesCommon = [self.names[0]]
for i in range(1, len(self.names)):
if (self.namesCount[i] == currentHigh):
self.namesCommon.append(self.names[i])
elif (self.namesCount[i] > currentHigh):
currentHigh = self.namesCount[i]
self.namesCommon = [self.names[i]]
return self.namesCommon
else:
return self.namesCommon
def getCommonNamesString(self, sepSequence):
if (self.recalcCommon):
self.getCommonNames()
namesString = self.namesCommon[0]
for i in range(1, len(self.namesCommon)):
namesString += sepSequence + self.namesCommon[i]
return namesString
def getTotalFlipnotes(self):
return len(self.flipnotes)
def getFlipnote(self, index):
return self.flipnotes[index]
def addName(self, newName):
newName = newName.strip()
self.recalcCommon = True # Most common name/s will need to be recalculated
foundName = False
# Look for the given name in the list of names
for i in range(len(self.names)):
if (newName == self.names[i]):
foundName = True
self.namesCount[i] += 1 # Add one to the number of times this name occurs
break
# If it's not there, add it
if (not foundName):
i = len(self.names)
self.names += [newName]
self.namesCount += [1] # Initialize an occurrence value (1) for the newly added name
def clearNames(self):
self.names = []
def addFlipnote(self, newFlip):
self.flipnotes += [newFlip]
def clearFlipnotes(self):
self.flipnotes = []
# Class for storing some relevant info about a Flipnote
class FlipnoteData:
def __init__(self, filenameDisk, filenameOriginal, filenameCurrent, idOriginal, idEditor, nameOriginal, nameEditor, dateStored, timeStored, isPpm, isLocked):
self.nameDisk = filenameDisk
self.nameOrig = filenameOriginal
self.nameCurr = filenameCurrent
self.idOrig = idOriginal
self.idEdit = idEditor
self.userOrig = nameOriginal
self.userEdit = nameEditor
self.date = dateStored
self.time = timeStored
self.ppm = isPpm
self.lock = isLocked
def getFilenameOnDisk(self):
return self.nameDisk
def getFilenameOriginal(self):
return self.nameOrig
def getFilenameCurrent(self):
return self.nameCurr
def getIdOriginal(self):
return self.idOrig
def getIdEditor(self):
return self.idEdit
def getNameOriginal(self):
return self.userOrig
def getNameEditor(self):
return self.userEdit
def getDateStored(self):
return self.date
def getTimeStored(self):
return self.time
def isPpm(self):
return self.ppm
def isKwz(self):
return (not self.ppm)
def isLocked(self):
return self.lock