ulduldp commited on
Commit
8490f49
·
verified ·
1 Parent(s): fdc38b4

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +26 -0
utils.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import random
3
+ import string
4
+
5
+ MAX_STORAGE = 15 * 1024 * 1024 * 1024
6
+
7
+ def storage_bar(used):
8
+ ratio = used / MAX_STORAGE if MAX_STORAGE else 0
9
+ filled = int(ratio * 10)
10
+ return "█"*filled + "░"*(10-filled)
11
+
12
+ def get_icon(name):
13
+ ext = name.lower().split('.')[-1]
14
+ if ext == "pdf": return "📄"
15
+ if ext in ["mp4","mkv"]: return "🎥"
16
+ if ext in ["jpg","png","jpeg"]: return "🖼"
17
+ return "📦"
18
+
19
+ def gen_pass():
20
+ return ''.join(random.choices(string.ascii_letters+string.digits,k=16))
21
+
22
+ def hash_pass(p):
23
+ return hashlib.sha256(p.encode()).hexdigest()
24
+
25
+ def breadcrumb(path):
26
+ return " > ".join(path)