-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_pico8.py
30 lines (28 loc) · 1.2 KB
/
generate_pico8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/env python
import shutil
import re
with open('missing.p8', 'w') as f:
lua_content = None
missing_content = None
with open('missing.lua', 'r') as r:
lua_content = ""
for line in r:
if re.match(r'^ {12}[\w.]+', line) is not None:
line = re.sub(r'^ {12}([\w.]+)', r' \1', line)
elif re.match(r'^ {10}[\w.]+', line) is not None:
line = re.sub(r'^ {10}([\w.]+)', r' \1', line)
elif re.match(r'^ {8}[\w.]+', line) is not None:
line = re.sub(r'^ {8}([\w.]+)', r' \1', line)
elif re.match(r'^ {6}[\w.]+', line) is not None:
line = re.sub(r'^ {6}([\w.]+)', r' \1', line)
elif re.match(r'^ {4}[\w.]+', line) is not None:
line = re.sub(r'^ {4}([\w.]+)', r' \1', line)
elif re.match(r'^ {2}[\w.]+', line) is not None:
line = re.sub(r'^ {2}([\w.]+)', r' \1', line)
lua_content += line
r.close()
with open('template_missing.p8', 'r') as r:
missing_content = r.read()
r.close()
missing_content = re.sub(r'\#insert_missing\#', lua_content, missing_content)
f.write(missing_content)