-
Notifications
You must be signed in to change notification settings - Fork 5
/
pack.py
executable file
·39 lines (33 loc) · 1017 Bytes
/
pack.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
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
import os
import subprocess
import sys
import re
# files of interest
sources = []
media = set()
media.add('Ubuntu-B.ttf')
for directory, dirnames, filenames in os.walk('.'):
for filename in filenames:
name, extension = os.path.splitext(filename)
if extension[1:] == 'lua':
localPath = os.path.join(directory, filename)
sources.append(localPath)
# scan script files for references to media files
with open(localPath, 'r') as textfile:
filetext = textfile.read()
matches = re.findall(r'["\']patches/.*?/.*?\.[\w]{3}["\']', filetext)
for m in matches:
media.add(m[1:-1])
media = list(media)
# sort lists for better overview in console output
media.sort()
sources.sort()
pathlist = ' '.join(sources + media)
try:
os.remove('game.love')
except:
pass
status, output = subprocess.getstatusoutput('zip game.love ' + pathlist)
print(output)
print('Created game.love with size %1.2f Mb' % (os.path.getsize('./game.love') * 1E-6))