Skip to content

Instantly share code, notes, and snippets.

@uyjulian
Created July 5, 2020 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uyjulian/e81b4e4168e10560645ed2b555b79e7b to your computer and use it in GitHub Desktop.
Save uyjulian/e81b4e4168e10560645ed2b555b79e7b to your computer and use it in GitHub Desktop.
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