-
Notifications
You must be signed in to change notification settings - Fork 0
/
pycli.py
63 lines (55 loc) · 1.22 KB
/
pycli.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import ast
def is_valid_python(code):
try:
ast.parse(code)
except SyntaxError:
return False
return True
ask = ""
test = 0
run = 0
def ifDone():
global test
global run
ask = input("... ")
if str(ask) == "":
pass
test = "true"
else:
test = ask
if test == "true":
pass
else:
run = run + test
ifDone()
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
print(color.RED + "Welcome to the " + color.END + color.GREEN + color.BOLD + "PyCLI" + color.END + color.END + ", The new Python CLI")
print("Python " + sys.version)
print("")
print("")
while True:
try:
run = input(">>> ")
if ":" in run:
run = run + input("... ")
ifDone()
run = run.replace("\t", "\n\t")
exec(run)
except Exception:
valid = str(is_valid_python(run))
if valid == "True":
pass
else:
print(color.BLUE + "This code is not valid." + color.END)
pass