Spaces:
Sleeping
Sleeping
thewellermangroup
commited on
Commit
·
72d5439
1
Parent(s):
a7eb09d
Create functions.py
Browse files- functions.py +41 -0
functions.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
f = open("FUNCTIONS.txt",'r',encoding="utf-8")
|
2 |
+
functions0 = f.read()
|
3 |
+
f.close()
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
functions1 = functions0.split('\nfunction ')
|
8 |
+
|
9 |
+
functions1 = functions1[1:]
|
10 |
+
|
11 |
+
# print(functions1)
|
12 |
+
|
13 |
+
BACKEND = ""
|
14 |
+
FRONTEND = ""
|
15 |
+
|
16 |
+
num = 0
|
17 |
+
|
18 |
+
for fun in functions1:
|
19 |
+
n = fun.split('{', 1)[0].strip()
|
20 |
+
f = fun.split('{', 1)[1].rsplit('}', 1)[0].strip().replace("\\","\\\\")
|
21 |
+
BACKEND += "'" + n + "': '''\n" + f + "\n''',\n"
|
22 |
+
FRONTEND += "function "+n+" {\n fetchApiData();\n // Ensure that globalData is populated before executing the code\n setTimeout(() => {\n if (BACKENDDATA.ACCESS) {\n eval(BACKENDDATA.FUNCTIONS['"+n+"']);\n }\n }, DELAYTIME);\n}\n"
|
23 |
+
num += 1
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
print(BACKEND)
|
28 |
+
print(FRONTEND)
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
print(num)
|
34 |
+
|
35 |
+
f = open("FUNCTIONS_BACKEND.txt",'w',encoding="utf-8")
|
36 |
+
f.write(BACKEND)
|
37 |
+
f.close()
|
38 |
+
|
39 |
+
f = open("FUNCTIONS_FRONTEND.txt",'w',encoding="utf-8")
|
40 |
+
f.write(FRONTEND)
|
41 |
+
f.close()
|