-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
33 lines (29 loc) · 763 Bytes
/
util.py
File metadata and controls
33 lines (29 loc) · 763 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
import sys
import os
def key_pressed():
try:
import tty, termios
except ImportError:
try:
# probably Windows
import msvcrt
except ImportError:
# FIXME what to do on other platforms?
raise ImportError('getch not available')
else:
key = msvcrt.getch().decode('utf-8')
return key
else:
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
def clear_screen():
if os.name == "nt":
os.system('cls')
else:
os.system('clear')