1
+ import time , os , sys , getpass , re , string
2
+
3
+ fp = input ('FilePath: ' )
4
+
5
+ if '.ps' in fp :
6
+ try :
7
+ f = open (f'{ fp } ' )
8
+ except :
9
+ exit ()
10
+ else :
11
+ exit ()
12
+
13
+ content = f .read ()
14
+ colist = content .split ("\n " )
15
+
16
+ def check ():
17
+ df = re .findall ("(?<=[AZaz])?(?!\d*=)[0-9.+-]+" , lines )
18
+ df = str (df )
19
+
20
+ def wait_until (somepredicate , timeout , period = 0.25 , * args , ** kwargs ):
21
+ mustend = time .time () + timeout
22
+ while time .time () < mustend :
23
+ if somepredicate (* args , ** kwargs ): return True
24
+ time .sleep (period )
25
+ return False
26
+
27
+ allvars = {}
28
+ line = 0
29
+ read_line = 0
30
+ getChar1 = "none"
31
+ getChar2 = "none"
32
+ getChar3 = "none"
33
+ var1 = "Undefined variable"
34
+ input1 = "Undefined input"
35
+ input2 = "Undefined input"
36
+ input3 = "Undefined input"
37
+
38
+
39
+ def pTAG ():
40
+ try :
41
+ if '</p>' in lines :#maybe replace </p> with </>?
42
+ wrd = '<p>'
43
+ res = lines .partition (wrd )[2 ]
44
+ res = res .replace ('</p>' , '' )
45
+ #res = res.replace(' ', '')
46
+ res = res .replace ('{getChar1}' , getChar1 )
47
+ res = res .replace ('{getChar2}' , getChar2 )
48
+ res = res .replace ('{getChar3}' , getChar3 )
49
+ res = res .replace ("{{input1}}" , input1 )
50
+ res = res .replace ("{{input2}}" , input2 )
51
+ res = res .replace ("{{input3}}" , input3 )
52
+ res = res .replace ("{{var1}}" , var1 )
53
+
54
+ if "{{" in res :
55
+ if "}}" in res :
56
+ start = "{{"
57
+ end = "}}"
58
+ check = res [res .find (start ) + len (start ):res .rfind (end )]
59
+
60
+ if check in allvars :
61
+ res = res .replace ('{{' ,'' )
62
+ res = res .replace ('}}' ,'' )
63
+ e = allvars [check ]
64
+ res = res .replace (check , str (e ))
65
+ else :
66
+ exit ()#add error
67
+
68
+ #wait_until("</p>", 0)
69
+ split_string = res .split ("</p>" , - 1 )
70
+ res = split_string [0 ]
71
+ print (res )
72
+ else :
73
+ pass
74
+ except :
75
+ exit ()
76
+
77
+
78
+ newvar = 0
79
+ file = open (fp )
80
+ readline2 = 0
81
+ for lines in file .readlines ():
82
+ if "/*" in lines :
83
+ wait_until ("*/" , 0 )
84
+ readline2 = 1
85
+ if readline2 == 1 :
86
+ continue
87
+ if "//" in lines :#maybe change to /#
88
+ readline2 = 1
89
+
90
+ line += 1
91
+ lines = lines .replace ('\n ' ,'' )
92
+ lines = lines .replace ('\t ' ,'' )
93
+ if lines == '' :
94
+ pass
95
+ elif lines in string .whitespace :
96
+ pass
97
+ elif "/*" in lines :
98
+ wait_until ("*/" , 0 )
99
+ pass
100
+ elif "//" in lines :
101
+ pass
102
+ lines = lines .rstrip ()
103
+
104
+ if "var " in lines :
105
+ wrd = "var "
106
+ newvar = lines .partition (wrd )[2 ]
107
+ split_string = newvar .split ("\" )" , - 1 )
108
+ newvar .replace (")" ,"" )
109
+ newvar .replace ('\" ' , '' )
110
+ newvar = split_string [0 ]
111
+ allvars [newvar ] = 0
112
+
113
+ if "//" in lines :
114
+ pass
115
+ read_line = 0
116
+ elif "window.prompt(" in lines :
117
+ wrd = "window.prompt("
118
+ var = lines .partition (wrd )[2 ]
119
+ split_string = var .split (");" , - 1 )
120
+ var .replace (');' ,'' )
121
+ var .replace ('\" ' ,"" )
122
+ var = split_string [0 ]
123
+ var .strip (");" )
124
+
125
+ if var in allvars :
126
+ var = input ()
127
+ allvars [newvar ] = var
128
+ else :
129
+ if var not in allvars :
130
+ exit ()#error
131
+ else :
132
+ exit ()#error
133
+
134
+ else :
135
+ pass
0 commit comments