materrine 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
materrine/__init__.py
ADDED
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
# Materrine™ - Database for everyone.
|
|
2
|
+
# WHAT YOU SEE IS WHAT YOU GET.
|
|
3
|
+
|
|
4
|
+
#Marcy Mill
|
|
5
|
+
################################################
|
|
6
|
+
# Codes.
|
|
7
|
+
|
|
8
|
+
# Packages.
|
|
9
|
+
|
|
10
|
+
import time
|
|
11
|
+
import random
|
|
12
|
+
import shelve
|
|
13
|
+
import os
|
|
14
|
+
import numpy as np
|
|
15
|
+
import sys
|
|
16
|
+
import getpass
|
|
17
|
+
|
|
18
|
+
# Classes.
|
|
19
|
+
|
|
20
|
+
class MaterrineInfoError(Exception):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
class MaterrineTypeError(Exception):
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
class MaterrineLenghtError(Exception):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
class MaterrineMatchError(Exception):
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
class MaterrineSurpriseNotAnError(Exception):
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
class MaterrineOwnershipError(Exception):
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
class MaterrineNameError(Exception):
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
# Values.
|
|
42
|
+
|
|
43
|
+
d1 = np.zeros((120, 120), dtype=object)
|
|
44
|
+
d2 = np.zeros((120, 120), dtype=object)
|
|
45
|
+
d3 = np.zeros((120, 120), dtype=object)
|
|
46
|
+
d4 = np.zeros((120, 120), dtype=object)
|
|
47
|
+
d5 = np.zeros((120, 120), dtype=object)
|
|
48
|
+
d6 = np.zeros((120, 120), dtype=object)
|
|
49
|
+
d7 = np.zeros((120, 120), dtype=object)
|
|
50
|
+
d8 = np.zeros((120, 120), dtype=object)
|
|
51
|
+
d9 = np.zeros((120, 120), dtype=object)
|
|
52
|
+
d10 = np.zeros((120, 120), dtype=object)
|
|
53
|
+
|
|
54
|
+
users = []
|
|
55
|
+
passwords = []
|
|
56
|
+
|
|
57
|
+
# Colour codes.
|
|
58
|
+
|
|
59
|
+
fg_colors = {
|
|
60
|
+
"black": "\033[90m",
|
|
61
|
+
"red": "\033[91m",
|
|
62
|
+
"green": "\033[92m",
|
|
63
|
+
"yellow": "\033[93m",
|
|
64
|
+
"blue": "\033[94m",
|
|
65
|
+
"magenta": "\033[95m",
|
|
66
|
+
"cyan": "\033[96m",
|
|
67
|
+
"white": "\033[97m"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
bg_colors = {
|
|
71
|
+
"black": "\033[100m",
|
|
72
|
+
"red": "\033[101m",
|
|
73
|
+
"green": "\033[102m",
|
|
74
|
+
"yellow": "\033[103m",
|
|
75
|
+
"blue": "\033[104m",
|
|
76
|
+
"magenta": "\033[105m",
|
|
77
|
+
"cyan": "\033[106m",
|
|
78
|
+
"white": "\033[107m"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Colouring function.
|
|
82
|
+
def colour(text, fg="white", bold=False, bg=None):
|
|
83
|
+
prefix = ""
|
|
84
|
+
if bold:
|
|
85
|
+
prefix += "\033[1m"
|
|
86
|
+
prefix += fg_colors.get(fg.lower(), "\033[97m")
|
|
87
|
+
if bg:
|
|
88
|
+
prefix += bg_colors.get(bg.lower(), "")
|
|
89
|
+
return f"{prefix}{text}\033[0m"
|
|
90
|
+
|
|
91
|
+
# Core database functions.
|
|
92
|
+
storage_path = os.path.join(os.path.dirname(__file__), "data.db")
|
|
93
|
+
|
|
94
|
+
def load_data():
|
|
95
|
+
with shelve.open(storage_path) as db:
|
|
96
|
+
d1 = db.get("d1", np.zeros((120, 120), dtype=object))
|
|
97
|
+
d2 = db.get("d2", np.zeros((120, 120), dtype=object))
|
|
98
|
+
d3 = db.get("d3", np.zeros((120, 120), dtype=object))
|
|
99
|
+
d4 = db.get("d4", np.zeros((120, 120), dtype=object))
|
|
100
|
+
d5 = db.get("d5", np.zeros((120, 120), dtype=object))
|
|
101
|
+
d6 = db.get("d6", np.zeros((120, 120), dtype=object))
|
|
102
|
+
d7 = db.get("d7", np.zeros((120, 120), dtype=object))
|
|
103
|
+
d8 = db.get("d8", np.zeros((120, 120), dtype=object))
|
|
104
|
+
d9 = db.get("d9", np.zeros((120, 120), dtype=object))
|
|
105
|
+
d10 = db.get("d10", np.zeros((120, 120), dtype=object))
|
|
106
|
+
users = db.get("users", [])
|
|
107
|
+
passwords = db.get("passwords", [])
|
|
108
|
+
return d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords):
|
|
114
|
+
with shelve.open(storage_path, "c") as db:
|
|
115
|
+
db["d1"] = d1
|
|
116
|
+
db["d2"] = d2
|
|
117
|
+
db["d3"] = d3
|
|
118
|
+
db["d4"] = d4
|
|
119
|
+
db["d5"] = d5
|
|
120
|
+
db["d6"] = d6
|
|
121
|
+
db["d7"] = d7
|
|
122
|
+
db["d8"] = d8
|
|
123
|
+
db["d9"] = d9
|
|
124
|
+
db["d10"] = d10
|
|
125
|
+
db["users"] = users
|
|
126
|
+
db["passwords"] = passwords
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords = load_data()
|
|
130
|
+
|
|
131
|
+
# Tools functions.
|
|
132
|
+
|
|
133
|
+
def login(username=None, pwd=None):
|
|
134
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
135
|
+
if username is None or pwd is None:
|
|
136
|
+
username = input("Enter your username here: ")
|
|
137
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
138
|
+
if passwords[users.index(username)] == pwd:
|
|
139
|
+
print(f"Welcome back, {username}! ")
|
|
140
|
+
return True
|
|
141
|
+
else:
|
|
142
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
143
|
+
else:
|
|
144
|
+
if passwords[users.index(username)] == pwd:
|
|
145
|
+
return True
|
|
146
|
+
else:
|
|
147
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
148
|
+
|
|
149
|
+
def register(name=None, password=None):
|
|
150
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
151
|
+
if name is None or password is None:
|
|
152
|
+
name = input("Enter your new username here: ")
|
|
153
|
+
password = getpass.getpass("Enter your new password here: ")
|
|
154
|
+
rpassword = getpass.getpass("Enter your new password here again: ")
|
|
155
|
+
rpassword = password
|
|
156
|
+
if password != rpassword:
|
|
157
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
158
|
+
if name not in users:
|
|
159
|
+
users.append(str(name))
|
|
160
|
+
passwords.append(str(password))
|
|
161
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
162
|
+
return True
|
|
163
|
+
else:
|
|
164
|
+
raise MaterrineNameError(f"Username '{name}' is existed. ")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def store(tar, ct, whom1=None, password1=None):
|
|
168
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
169
|
+
if type(ct) != list:
|
|
170
|
+
raise MaterrineTypeError("Element 'tags' must be a list. ")
|
|
171
|
+
if len(ct) > 117:
|
|
172
|
+
raise MaterrineLengthError("Length of element 'tags' must be ≤117. Perhaps you can store other data in another database which has the same name as this one. ")
|
|
173
|
+
if password1 is None and whom1 is None:
|
|
174
|
+
whom1 = input("Registered name: ")
|
|
175
|
+
password1 = getpass.getpass(f"Password for {whom1}: ")
|
|
176
|
+
|
|
177
|
+
pl = []
|
|
178
|
+
if passwords[users.index(whom1)] == password1:
|
|
179
|
+
preparedList = []
|
|
180
|
+
for i in range(120):
|
|
181
|
+
preparedList.append(0)
|
|
182
|
+
preparedList[0] = whom1
|
|
183
|
+
preparedList[1] = tar
|
|
184
|
+
for i in range(len(ct)):
|
|
185
|
+
preparedList[i + 2] = ct[i]
|
|
186
|
+
preparedList[len(ct) + 3] = "END"
|
|
187
|
+
pos = np.argwhere(d1 == whom1)
|
|
188
|
+
for i in range(len(pos)):
|
|
189
|
+
if pos[i][0] == 0:
|
|
190
|
+
pl.append(i)
|
|
191
|
+
p = []
|
|
192
|
+
for i in range(len(pl)):
|
|
193
|
+
if d1[pl[i]][1] != 0:
|
|
194
|
+
p.append("NotFound")
|
|
195
|
+
else:
|
|
196
|
+
d1[pl[i]][1] = tar
|
|
197
|
+
for j in range(len(ct)):
|
|
198
|
+
d1[pl[i]][j + 2] = ct[j]
|
|
199
|
+
d1[pl[i]][len(ct) + 2] = "END"
|
|
200
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
201
|
+
return d1[pl[i]]
|
|
202
|
+
if len(p) == len(pl):
|
|
203
|
+
d1 = np.vstack((d1, preparedList))
|
|
204
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
205
|
+
return d1[len(d1) - 1]
|
|
206
|
+
else:
|
|
207
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def view_all(pwd):
|
|
212
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
213
|
+
if pwd == passwords[0]:
|
|
214
|
+
return users, passwords, d1
|
|
215
|
+
|
|
216
|
+
def view_database(pwd):
|
|
217
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
218
|
+
if pwd == passwords[0]:
|
|
219
|
+
return d1
|
|
220
|
+
|
|
221
|
+
def view_users(pwd):
|
|
222
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
223
|
+
if pwd == passwords[0]:
|
|
224
|
+
return users
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def view_pwd(pwd):
|
|
229
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
230
|
+
if pwd == passwords[0]:
|
|
231
|
+
return passwords
|
|
232
|
+
|
|
233
|
+
def clear(pwd):
|
|
234
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
235
|
+
if pwd == passwords[0]:
|
|
236
|
+
d1 = np.zeros((120, 120), dtype=object)
|
|
237
|
+
d2 = np.zeros((120, 120), dtype=object)
|
|
238
|
+
d3 = np.zeros((120, 120), dtype=object)
|
|
239
|
+
d4 = np.zeros((120, 120), dtype=object)
|
|
240
|
+
d5 = np.zeros((120, 120), dtype=object)
|
|
241
|
+
d6 = np.zeros((120, 120), dtype=object)
|
|
242
|
+
d7 = np.zeros((120, 120), dtype=object)
|
|
243
|
+
d8 = np.zeros((120, 120), dtype=object)
|
|
244
|
+
d9 = np.zeros((120, 120), dtype=object)
|
|
245
|
+
d10 = np.zeros((120, 120), dtype=object)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
users = users[1:len(users)]
|
|
249
|
+
passwords = passwords[1:len(passwords)]
|
|
250
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
251
|
+
return True
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def is_pos(num):
|
|
256
|
+
if num != 0 and num == abs(num):
|
|
257
|
+
return True
|
|
258
|
+
else:
|
|
259
|
+
return False
|
|
260
|
+
|
|
261
|
+
def is_valid(line, pos):
|
|
262
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
263
|
+
endpos = max(i for i, v in enumerate(line) if v == "END")
|
|
264
|
+
if pos < endpos and is_pos(pos):
|
|
265
|
+
return True
|
|
266
|
+
else:
|
|
267
|
+
return False
|
|
268
|
+
|
|
269
|
+
def is_dups(l):
|
|
270
|
+
workable = []
|
|
271
|
+
for i in l:
|
|
272
|
+
if i in workable:
|
|
273
|
+
return False
|
|
274
|
+
else:
|
|
275
|
+
workable.append(i)
|
|
276
|
+
return True
|
|
277
|
+
|
|
278
|
+
def nodups(l):
|
|
279
|
+
outputs = []
|
|
280
|
+
for i in l:
|
|
281
|
+
if i in outputs:
|
|
282
|
+
continue
|
|
283
|
+
else:
|
|
284
|
+
outputs.append(i)
|
|
285
|
+
return outputs
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def search(tar, username=None, pwd=None):
|
|
289
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
290
|
+
if username is None or pwd is None:
|
|
291
|
+
username = input("Enter your username here: ")
|
|
292
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
293
|
+
outputs = []
|
|
294
|
+
main = []
|
|
295
|
+
cons = []
|
|
296
|
+
if passwords[users.index(username)] == pwd:
|
|
297
|
+
userbase = mine(username, pwd)
|
|
298
|
+
for i in userbase:
|
|
299
|
+
for j, k in enumerate(i):
|
|
300
|
+
if k == tar and j != 0 and is_valid(i, j):
|
|
301
|
+
if j == 1:
|
|
302
|
+
cons.extend(i[2:])
|
|
303
|
+
else:
|
|
304
|
+
main.append(i[1])
|
|
305
|
+
main = nodups(main)
|
|
306
|
+
outputs.append(main)
|
|
307
|
+
outputs.append(cons)
|
|
308
|
+
return outputs
|
|
309
|
+
else:
|
|
310
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
311
|
+
|
|
312
|
+
def tags(tar, username=None, pwd=None):
|
|
313
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
314
|
+
if username is None or pwd is None:
|
|
315
|
+
username = input("Enter your username here: ")
|
|
316
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
317
|
+
o = search(tar, username, pwd)
|
|
318
|
+
return o[1]
|
|
319
|
+
|
|
320
|
+
def data(tar, username=None, pwd=None):
|
|
321
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
322
|
+
if username is None or pwd is None:
|
|
323
|
+
username = input("Enter your username here: ")
|
|
324
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
325
|
+
o = search(tar, username, pwd)
|
|
326
|
+
return o[0]
|
|
327
|
+
|
|
328
|
+
def mine(username=None, pwd=None):
|
|
329
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
330
|
+
userbase = []
|
|
331
|
+
if username is None and pwd is None:
|
|
332
|
+
username = input("Enter your username here: ")
|
|
333
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
334
|
+
if passwords[users.index(username)] == pwd:
|
|
335
|
+
for j, k in enumerate(d1):
|
|
336
|
+
if k[0] == username:
|
|
337
|
+
userbase.append(k)
|
|
338
|
+
return userbase
|
|
339
|
+
else:
|
|
340
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
341
|
+
|
|
342
|
+
def view(pos, username=None, pwd=None):
|
|
343
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
344
|
+
if type(pos) != list:
|
|
345
|
+
raise MaterrineTypeError("Element 'pos' must be a list. ")
|
|
346
|
+
if username is None or pwd is None:
|
|
347
|
+
username = input("Enter your username here: ")
|
|
348
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
349
|
+
if passwords[users.index(username)] == pwd and d1[pos[0]][0] == username and is_valid(d1[pos[0]], pos[1]):
|
|
350
|
+
return d1[pos[0]][pos[1]]
|
|
351
|
+
else:
|
|
352
|
+
raise MaterrineInfoError("Username or password or position invalid. ")
|
|
353
|
+
|
|
354
|
+
def delete(pos, username=None, pwd=None):
|
|
355
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
356
|
+
if type(pos) != list:
|
|
357
|
+
raise MaterrineTypeError("Element 'pos' must be a list. ")
|
|
358
|
+
if username is None or pwd is None:
|
|
359
|
+
username = input("Enter your username here: ")
|
|
360
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
361
|
+
if passwords[users.index(username)] == pwd:
|
|
362
|
+
if d1[pos[0]][0] == username and is_valid(d1[pos[0]], pos[1]):
|
|
363
|
+
d1[pos[0]][pos[1]] = 0
|
|
364
|
+
bp = max(i for i, v in enumerate(d1[pos[0]]) if v == "END")
|
|
365
|
+
d1[pos[0]][bp] = 0
|
|
366
|
+
d1[pos[0]][bp - 1] = "END"
|
|
367
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
368
|
+
return True
|
|
369
|
+
else:
|
|
370
|
+
raise MaterrineOwnershipError("The place where you wanted to delete is not yours. ")
|
|
371
|
+
else:
|
|
372
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def fill(pos, fillby, username=None, pwd=None):
|
|
376
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
377
|
+
if type(pos) != list:
|
|
378
|
+
raise MaterrineTypeError("Element 'pos' must be a list. ")
|
|
379
|
+
if username is None or pwd is None:
|
|
380
|
+
username = input("Enter your username here: ")
|
|
381
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
382
|
+
if passwords[users.index(username)] == pwd and d1[pos[0]][0] == username and is_valid(d1[pos[0]], pos[1]):
|
|
383
|
+
d1[pos[0]][pos[1]] = fillby
|
|
384
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
385
|
+
return True
|
|
386
|
+
else:
|
|
387
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
388
|
+
|
|
389
|
+
def jfill(line, tar, fillby, username=None, pwd=None):
|
|
390
|
+
if username is None or pwd is None:
|
|
391
|
+
username = input("Enter your username here: ")
|
|
392
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
393
|
+
if passwords[users.index(username)] == pwd and d1[line][0] == username and tar in d1[line]:
|
|
394
|
+
outputs = []
|
|
395
|
+
for i, v in enumerate(d1[line]):
|
|
396
|
+
if v == tar and is_valid(d1[line], i):
|
|
397
|
+
outputs.append(fillby)
|
|
398
|
+
else:
|
|
399
|
+
outputs.append(v)
|
|
400
|
+
d1[line] == outputs
|
|
401
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
402
|
+
return True
|
|
403
|
+
else:
|
|
404
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
405
|
+
|
|
406
|
+
def line(line, username=None, pwd=None):
|
|
407
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
408
|
+
if username is None or pwd is None:
|
|
409
|
+
username = input("Enter your username here: ")
|
|
410
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
411
|
+
if passwords[users.index(username)] == pwd and d1[line][0] == username:
|
|
412
|
+
return d1[line]
|
|
413
|
+
else:
|
|
414
|
+
raise MaterrineInfoError("Username or password or position invalid. ")
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def get(tar, username=None, pwd=None):
|
|
418
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
419
|
+
if username is None or pwd is None:
|
|
420
|
+
username = input("Enter your username here: ")
|
|
421
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
422
|
+
if passwords[users.index(username)] == pwd:
|
|
423
|
+
userbase = [i for i, v in enumerate(d1) if v[0] == username]
|
|
424
|
+
allpos = []
|
|
425
|
+
for i in userbase:
|
|
426
|
+
if tar in d1[i].tolist():
|
|
427
|
+
poshere = [j for j, k in enumerate(d1[i]) if k == tar and is_valid(d1[i], j)]
|
|
428
|
+
allpos.append(i)
|
|
429
|
+
allpos.append(poshere)
|
|
430
|
+
return allpos
|
|
431
|
+
else:
|
|
432
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
433
|
+
|
|
434
|
+
# Edit user informations.
|
|
435
|
+
|
|
436
|
+
def change_password(username=None, pwd=None):
|
|
437
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
438
|
+
if username is None or pwd is None:
|
|
439
|
+
username = input("Enter your username here: ")
|
|
440
|
+
pwd = getpass.getpass("Enter your old password here: ")
|
|
441
|
+
pwd = str(pwd)
|
|
442
|
+
if passwords[users.index(username)] == pwd:
|
|
443
|
+
newpass = getpass.getpass("Enter your new password here: ")
|
|
444
|
+
newpasstwice = getpass.getpass("Enter your new password again: ")
|
|
445
|
+
if newpass == newpasstwice:
|
|
446
|
+
passwords[user.index(username)] == newpass
|
|
447
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
448
|
+
return True
|
|
449
|
+
else:
|
|
450
|
+
raise MaterrineMatchError("Passwords not matched. ")
|
|
451
|
+
else:
|
|
452
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
453
|
+
|
|
454
|
+
def change_username(username=None, pwd=None):
|
|
455
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
456
|
+
if username is None or pwd is None:
|
|
457
|
+
username = input("Enter your old username here: ")
|
|
458
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
459
|
+
if passwords[users.index(username)] == pwd:
|
|
460
|
+
nn = input("Enter your new username: ")
|
|
461
|
+
if nn in users:
|
|
462
|
+
raise MaterrineNameError(f"Name '{nn}' is existed. ")
|
|
463
|
+
else:
|
|
464
|
+
users[users.index(username)] = nn
|
|
465
|
+
save_data(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords)
|
|
466
|
+
return True
|
|
467
|
+
else:
|
|
468
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
# Surprise function room() !
|
|
472
|
+
def room(k):
|
|
473
|
+
if k == "Materrine™" or k == "Marcy is me" or k == "M":
|
|
474
|
+
raise MaterrineSurpriseNotAnError("Suprise! You just found the secret function room() ! This is the reward for the people who read my codes!")
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def total(username=None, pwd=None):
|
|
478
|
+
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, users, passwords
|
|
479
|
+
if username is None or pwd is None:
|
|
480
|
+
username = input("Enter your username here: ")
|
|
481
|
+
pwd = getpass.getpass("Enter your password here: ")
|
|
482
|
+
if passwords[users.index(username)] == pwd:
|
|
483
|
+
return len(mine(username, pwd))
|
|
484
|
+
else:
|
|
485
|
+
raise MaterrineInfoError("Username or password invalid. ")
|
|
486
|
+
|
|
487
|
+
# Infos functions.
|
|
488
|
+
|
|
489
|
+
def license():
|
|
490
|
+
mit = """
|
|
491
|
+
MIT License
|
|
492
|
+
|
|
493
|
+
Copyright (c) 2026 MarcyMill
|
|
494
|
+
|
|
495
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
496
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
497
|
+
in the Software without restriction, including without limitation the rights
|
|
498
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
499
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
500
|
+
furnished to do so, subject to the following conditions:
|
|
501
|
+
|
|
502
|
+
The above copyright notice and this permission notice shall be included in all
|
|
503
|
+
copies or substantial portions of the Software.
|
|
504
|
+
|
|
505
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
506
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
507
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
508
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
509
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
510
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
511
|
+
SOFTWARE.
|
|
512
|
+
"""
|
|
513
|
+
print(colour(mit, "green", bold = True, bg = None))
|
|
514
|
+
|
|
515
|
+
def author():
|
|
516
|
+
authorinfo = """
|
|
517
|
+
Marcy Mill is the author of Materrine™. He wrote Materrine™ alone in his study at home. He is a man which is attracted by the beauty of maths and by the beuaty of programming. He loves everything in this universe which is logical. His motto is "The process is the reward.". Visit his Github account which is barely nothing => MarcyMill. Anything you wants to say to him or maybe the improvements of Materrine™ you wants to share with him can be sent to his email address:
|
|
518
|
+
marcy@marphire.com. And he has another Python package called MarStar, which is an ultimate game platform. He even gots his own website marphire.com, but not fully finished.
|
|
519
|
+
You can ask @MarcyMill to help you with designing projects, he's boring. Marock™, Marphire™... is all his projects.
|
|
520
|
+
"""
|
|
521
|
+
print(colour(authorinfo, "cyan", bold = True, bg = None))
|
|
522
|
+
|
|
523
|
+
def help():
|
|
524
|
+
txt1 = """
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
Materrine™ - Database for everyone.
|
|
531
|
+
By Marcy
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|Manuals for Materrine™, MaterrineBase™, MaterrineMe™ and MaterrineMine™. |
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
-------------------------------------------------------------------------------------------------------------------------
|
|
538
|
+
Hint: all the functions below can add elements username and password behind to skip the user verifications. E. g. search(obj, YourUsername, YourPassword) aplied on every function.
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
register(): To register an account.
|
|
542
|
+
|
|
543
|
+
store(target, tags): To store data into MaterrineBase™, tags are the things related to target, in the format of a list.
|
|
544
|
+
|
|
545
|
+
search(obj): Search obj in your own database, will be outputs as this two-demensional-list-format below:
|
|
546
|
+
[[mainData1, mainData2...],
|
|
547
|
+
[tags1, tags2...]
|
|
548
|
+
] .
|
|
549
|
+
|
|
550
|
+
mine(): Which allows you to view your MaterrineMine™ - your own database.
|
|
551
|
+
|
|
552
|
+
delete(position): Delete the object on that position you mentioned.
|
|
553
|
+
|
|
554
|
+
fill(position, fillby): To fill the object in that position you mentioned by fillby.
|
|
555
|
+
|
|
556
|
+
help(): Here your are! To view our MaterrineUniversalManual™.
|
|
557
|
+
|
|
558
|
+
license(): To read our MIT license.
|
|
559
|
+
|
|
560
|
+
author(): To know better of Materrine™ 's author Marcy Mill.
|
|
561
|
+
|
|
562
|
+
change_password(): To change your password for your account.
|
|
563
|
+
|
|
564
|
+
jfill(line, target, fillby): To fill every targets you mentioned in the function in line by fillby.
|
|
565
|
+
|
|
566
|
+
login(): To view your infos. So-called 'MaterrineMe™'.
|
|
567
|
+
|
|
568
|
+
get(tar): Get the postion of tar.
|
|
569
|
+
|
|
570
|
+
view(pos): View specific position.
|
|
571
|
+
|
|
572
|
+
line(line): View specific row.
|
|
573
|
+
|
|
574
|
+
tags(tar): To view all the tags related to tar.
|
|
575
|
+
|
|
576
|
+
data(tar): To view all the data related to tar.
|
|
577
|
+
|
|
578
|
+
total(): To get the quantities of your database(s) .
|
|
579
|
+
|
|
580
|
+
|WHAT YOU SEE IS WHAT YOU GET|
|
|
581
|
+
|
|
582
|
+
"""
|
|
583
|
+
print(colour(txt1, "green", bold = True, bg = None))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: materrine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Materrine™ is a powerful, readable, relative database which allows you to store your data anywhere, anyplace. And also allows you to store tags related with data into the database. The powerful built-in searching function will search ALL the data related to your targets. With useful tools to help you to manage all you data, everyone is able to use it. Storing data by just one function. Use materrine.help() for more info. Created by Marcy Mill.
|
|
5
|
+
Author: Marcy Mill
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: numpy>=1.21
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
Materrine™ is a powerful, readable, relative database which allows you to store
|
|
14
|
+
your data anywhere, anyplace. And also allows you to store tags related with data
|
|
15
|
+
into the database. The powerful built-in searching function will search ALL the
|
|
16
|
+
data related to your targets. With useful tools to help you to manage all you data,
|
|
17
|
+
everyone is able to use it. Storing data by just one function. Use materrine.help()
|
|
18
|
+
for more info. Created by Marcy Mill.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
materrine/__init__.py,sha256=yoyU91tojxnnr-itbXLFhdb5EG10EXzo-y5D5qc17eo,18897
|
|
2
|
+
materrine-0.1.0.dist-info/licenses/LICENSE,sha256=EVbYN8FiOtm0dh5Mi_vAYn7s9N94Eu7_UMk3gVFFoo4,1067
|
|
3
|
+
materrine-0.1.0.dist-info/METADATA,sha256=bG2HU1W1e3Om8ucNOCekwNEYun5u8uuVKjQFD3BEgTI,1131
|
|
4
|
+
materrine-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
+
materrine-0.1.0.dist-info/top_level.txt,sha256=iDoulfXjTgUZ2l0GZEcHdoDA8pxsq0E3PEtP2Q6IWkU,10
|
|
6
|
+
materrine-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcy Mill
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
materrine
|