37 lines
753 B
Python
37 lines
753 B
Python
#!/usr/bin/env python3
|
|
|
|
import glob
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
|
|
TEMPLATE = r"""<?xml version="1.0" encoding="utf-8" ?>
|
|
<XnaContent>
|
|
<Asset Type="System.String">
|
|
<![CDATA[
|
|
%s
|
|
]]>
|
|
</Asset>
|
|
</XnaContent>
|
|
"""
|
|
|
|
|
|
def main(args):
|
|
this_dir = os.path.dirname(os.path.realpath(__file__))
|
|
sneak_root = os.path.join(this_dir, '..', '..', '..')
|
|
os.chdir(sneak_root)
|
|
|
|
json_files = sorted(glob.glob('Content/sprites/**/*.json', recursive=True))
|
|
for json_file in json_files:
|
|
with open(json_file) as json:
|
|
outfile_name = re.sub(r'.json$', '_json.xml', json_file)
|
|
result = TEMPLATE % json.read()
|
|
with open(outfile_name, 'w') as out:
|
|
out.write(result)
|
|
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv[1:]))
|