1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-25 05:36:22 -07:00

Add #if flag markers in sql macro script

Made some changes
This commit is contained in:
comraderat 2020-06-11 17:20:59 +02:00
parent 72eb7e5467
commit 3905ec1393
4 changed files with 67 additions and 35 deletions

View file

@ -15,14 +15,30 @@ macros = [
macro("drop fk", "DROP CONSTRAINT", "DROP FOREIGN KEY")
]
def compileOutIfs(text, flag):
lines = text.splitlines()
newText = ""
compile = True
for i in lines:
if "#IF" in i:
if flag in i:
compile = True
else:
compile = False
elif "#ENDIF" in i:
compile = True
elif compile:
newText += i + "\n"
return newText
def dofile(filestart):
print("building " + filestart + " sql file")
masterfileIn = open(filestart + "master.sql", 'r')
masterfile = masterfileIn.read()
masterfileIn.close()
postgresProcessed = masterfile
mysqlProcessed = masterfile
postgresProcessed = compileOutIfs(masterfile, "POSTGRES")
mysqlProcessed = compileOutIfs(masterfile, "MYSQL")
for item in macros:
macroCode = "{" + item.macroname + "}"