summaryrefslogtreecommitdiff
path: root/src/util.py
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2021-11-20 17:24:42 +0000
committerdavidovski <david@davidovski.xyz>2021-11-20 17:24:42 +0000
commit8104e8fdb0821331972d4016189e71ea1606a6ef (patch)
tree50fe8a911a02d1e182e4c87905c8cf632b0b7c84 /src/util.py
parentbd8d23136d343e1465e0222f6030fea1cbd4cbf3 (diff)
added dependency resolving
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/util.py b/src/util.py
index 16df7bc..2411f1d 100644
--- a/src/util.py
+++ b/src/util.py
@@ -3,6 +3,7 @@ import requests
import colors
import time
import os
+import hashlib
DEFAULT_BAR_COLOR = colors.BLACK + colors.BG_CYAN
DEFAULT_BAR_COLOR_RESET = colors.BG_BLACK + colors.CYAN
@@ -25,8 +26,8 @@ def loading_bar(completed, total, text,
print(color + info, end="\r")
-
-
+def print_reset(text):
+ print(colors.RESET + text)
def curl(url):
r = requests.get(url)
@@ -36,6 +37,21 @@ def mkdir(path):
if not os.path.exists(path):
os.makedirs(path)
+def md5sum(data):
+ return hashlib.md5(data)
+
+def ask_confirmation(text, default=True, no_confirm=False):
+ yes = "Y" if default else "y"
+ no = "n" if default else "N"
+
+ if no_confirm:
+ reponse = "y" if default else "n"
+ print(f"{text} [{yes},{no}] {colors.RESET} {reponse}")
+ else:
+ reponse = input(f"{text} [{yes},{no}] " + colors.RESET)
+
+ return reponse.lower() == "y" or len(reponse) == 0
+
if __name__ == "__main__":
for i in range(1000):
loading_bar(i, 1000, "it is loading...")