summaryrefslogtreecommitdiff
path: root/rparse.py
blob: 0cdf35b43ac64685b816030b6706ca52d4433326 (plain) (blame)
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
import os, subprocess

def fm(f):
    return os.getcwd()+"/debug/"+f

for f in os.listdir(os.getcwd()+"/debug"):
    #print("mv \"%s\" \"%s\"" % (fm(f), fm(f.replace(".rpy", ".py"))))
    #subprocess.call("mv \"%s\" \"%s\"" % (fm(f), fm(f.replace(".rpy", ".py"))), shell=True)
    with open(os.getcwd()+"/debug/"+f, "r") as fp:
        on=False
        ind=""
        lv=0
        ft = open(os.getcwd()+"/debug/"+f+"-sast.py", "w")
        ft.write("""renpy=None; persistent=None; config=None; gui=None; h=None
def _(arg):
    return arg
def stdout(arg):
    return arg
def statusmsg(arg="", arg2=""):
    return arg
def handle_client(arg="", arg2=""):
    return arg
def md5check_client(arg="", arg2=""):
    return arg
def get_path(arg="", arg2=""):
    return arg
import requests
""")
        ft.write("if True:\n")
        for l in fp:
            if on:
                if not l.startswith(ind):
                    on=False
                    continue
                ft.write(l)
                if ind == "":
                    for c in l:
                        if c == " ":
                            ind+=" "
            if "python" in l:
                on=True
                ind=""
            if " $" in l:
                ft.write("    "+l.replace("$", "").lstrip())
        ft.close()

subprocess.call("ls \"%s\"" % os.getcwd()+"/debug", shell=True) # nosec