forked from ntaulbut/hn84-python-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (26 loc) · 902 Bytes
/
utils.py
File metadata and controls
38 lines (26 loc) · 902 Bytes
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
from time import sleep
from sys import platform
from os import system
TOP_LINE = "┌" + "─" * 78 + "┐\n"
DIV_LINE = "├" + "─" * 78 + "┤\n"
BOTTOM_LINE = "└" + "─" * 78 + "┘"
def clear():
# clears terminal
if platform == "win32":
_ = system("cls")
else:
_ = system("clear")
def dprint(text: str, before: int = 1, after: int = 0, *args, **kwargs):
# Print with a delay before and/or after
sleep(before)
print(text, *args, **kwargs)
sleep(after)
def print_art(name: str):
with open(f"art/{name}.txt", "r", encoding="utf-8") as file:
print(file.read())
def inc_b(old: int, max_i: int) -> int:
# Increment a value keeping it below or equal to a maximum
return min(old + 1, max_i)
def dec_b(old: int, min_i: int) -> int:
# Increment a value keeping it above or equal to a minimum
return max(old - 1, min_i)