tools: wixguid.py

This commit is contained in:
Bill Zissimopoulos
2021-04-13 15:22:42 -07:00
parent 3c7e712e57
commit aa7888effc
2 changed files with 18 additions and 2 deletions

16
tools/gensrc/wixguid.py Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/python
import re, sys, uuid
guid_re = re.compile("[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}")
guid_dt = {}
def mk_guid(m):
guid = m.group(0).upper()
if guid not in guid_dt:
guid_dt[guid] = str(uuid.uuid4()).upper()
return guid_dt[guid]
with open(sys.argv[1]) as file:
text = file.read()
text = guid_re.sub(mk_guid, text)
sys.stdout.write(text)