добавил много комментариев, везде, кроме Mathematics.py

This commit is contained in:
2023-01-16 18:05:27 +07:00
parent 957a54208f
commit 9575fd4b85
+20 -7
View File
@@ -1,8 +1,21 @@
from modules.DB import UseDB
from zipfile import ZipFile
db = UseDB("events")
for i in db.find_document({}):
print(i)
# db.del_document({"name": i["name"]})
# db.update_document({"name": "test not bad"}, {"probability": 50})
db.update_document({"name": "test bad "}, {"probability": 50})
def human_read_format(size):
if size < 1024:
return f"{size}Б"
elif size < 1024 * 1024:
return f"{round(size / 1024)}КБ"
elif size < 1024 * 1024 * 1024:
return f"{round(size / (1024 * 1024))}МБ"
elif size < 1024 * 1024 * 1024 * 1024:
return f"{round(size / (1024 * 1024 * 1024))}ГБ"
with ZipFile('input.zip') as myzip:
for i, j in enumerate(myzip.filelist):
items = myzip.namelist()[i].rstrip("/").split("/")
if myzip.namelist()[i][-1] == "/":
print(" " * (len(items) - 1) + items[-1])
else:
print(f'{" " * (len(items) - 1) + items[-1]} {human_read_format(j.file_size)}')