Created
July 5, 2020 19:49
-
-
Save uyjulian/e81b4e4168e10560645ed2b555b79e7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import json | |
importptr_match = re.compile('^if\\(!TVPImportFuncPtr(.*)\\)$') | |
externimportptr_match = re.compile('^extern void \\* TVPImportFuncPtr(.*);$') | |
outarr = [] | |
to_skip = 0 | |
with open(sys.argv[1]) as in_file: | |
for line in in_file: | |
if to_skip != 0: | |
to_skip -= 1 | |
continue | |
ln = line.lstrip() | |
matc = importptr_match.match(ln) | |
if matc is not None: | |
del outarr[-1] | |
del outarr[-1] | |
to_skip = 7 | |
if line[0] == '\t': | |
to_skip += 1 | |
continue | |
matc = externimportptr_match.match(ln) | |
if matc is not None: | |
continue | |
outarr.append(line) | |
with open(sys.argv[2], "w") as out_file: | |
out_file.write("".join(outarr)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment