Skip to content

Commit b5840ad

Browse files
committed
move things to misc
1 parent 1d41871 commit b5840ad

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*egg*/
22
.idea/
3-
.vscode/
43
build/
4+
.vscode/
5+
__pycache__/
56
_version.py
6-
pypi.token
7+
pypi.token

lokzzpylib/__init__.py

+6-23
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
except ImportError: windows = False
1111
else: windows = True
1212

13+
from .misc import *
14+
# misc_functions = [
15+
# ask_bool, ask_int, wind_getonekey,
16+
# clearsc, clearinp
17+
# ]
18+
1319
colorama.init()
1420

1521
class Choice:
@@ -310,15 +316,6 @@ def progress_bar2(start_time: float, current_time: float = time.time(), timetota
310316
progbarstring = '█' * timepassed + '░' * int(progbarsize - timepassed) + ' ' + str(round(remains, 2)).ljust(ljust, '0') + 's'
311317
return progbarstring
312318

313-
def ask_bool(prompt: str) -> bool:
314-
try: return {"true": True, "yes": True, "y": True, "false": False, "no": False, "n": False}[input(prompt).lower()]
315-
except KeyError: print("invalid input")
316-
317-
def ask_int(prompt: str) -> int:
318-
while True:
319-
try: return int(input(prompt))
320-
except ValueError: print("not a number")
321-
322319
def printc(n: str, *d, f: bool = False, nc = False, firstclr: object = colored.blue, sepL: int = 0, sepC: str = ' ', Beg: str = colored.green('//|'), BegL: int = 4, end: str = '\n', returnstring: bool = False, stream: None = None) -> str | None:
323320
sep = sepC * sepL; w = ''.join(map(str, d))
324321
if not f:
@@ -348,18 +345,4 @@ def formatdict(thing: dict | list , item_color: object = colored.white, key_colo
348345
def printd(n: str, d: str = '', f: bool = False, A: bool = False, sepL: int = 0, sepC: str = ' ', Beg: str = colored.red('>>|'), BegL: int = 4):
349346
if A: printc(n, d, f=f, sepL=sepL, sepC=sepC, Beg=Beg, BegL=BegL)
350347

351-
def wind_getonekey(f: bool = True) -> str:
352-
if not windows: return ''
353-
if f: return str(msvcrt.getch(), 'utf-8')
354-
else: return msvcrt.getch()
355-
356-
def clearsc(type: int = 1):
357-
if type == 1: print('\033[2J')
358-
elif type == 2: print('\n' * 25)
359-
360-
def clearinp(t: int = 25, e: bool = False):
361-
for i in range(t):
362-
keyboard.press_and_release("\b")
363-
if e: printc(f"on the {i + 1} backspace")
364-
365348
if __name__ == '__main__': exit()

lokzzpylib/misc.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from .__init__ import printc
2+
from .__init__ import windows
3+
from .__init__ import msvcrt, keyboard
4+
# how the fuck was this even allowed? circular import
5+
6+
def ask_bool(prompt: str) -> bool:
7+
try: return {"true": True, "yes": True, "y": True, "false": False, "no": False, "n": False}[input(prompt).lower()]
8+
except KeyError: print("invalid input")
9+
10+
def ask_int(prompt: str) -> int:
11+
while True:
12+
try: return int(input(prompt))
13+
except ValueError: print("not a number")
14+
15+
def wind_getonekey(f: bool = True) -> str:
16+
if not windows: return ''
17+
if f: return str(msvcrt.getch(), 'utf-8')
18+
else: return msvcrt.getch()
19+
20+
def clearsc(type: int = 1):
21+
if type == 1: print('\033[2J')
22+
elif type == 2: print('\n' * 25)
23+
24+
def clearinp(t: int = 25, v: bool = False):
25+
for i in range(t):
26+
keyboard.press_and_release("\b")
27+
if v: printc(f"on the {i + 1} backspace")

0 commit comments

Comments
 (0)