-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
46 lines (39 loc) · 1.46 KB
/
build.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
40
41
42
43
44
45
46
# libraries
import os
from zipfile import ZipFile
from catppuccin import PALETTE
import re
# read properties.xml
file = open('properties.xml', 'r')
theme = file.read()
file.close()
# make output directory
if not os.path.exists('output'):
os.mkdir('output')
# generate all flavors
for flavor in PALETTE:
with ZipFile('output/mixplorer-catppuccin-' + flavor.name + '.zip', 'w') as flavor_zip:
print('generating ' + flavor.name)
# get colors
colors = {}
for accent in flavor.colors:
colors[accent.identifier] = re.sub(r'^#', '', accent.hex)
# generate flavors
for accent in flavor.colors:
if accent.accent:
def replaceValues(match):
v = match.group(1)
if v == 'flavorName':
return flavor.name
elif v == 'accentName':
return accent.name
elif v == 'accent':
return colors[accent.identifier]
elif colors.get(v):
return colors[v]
result = re.sub(r'{{([\w\s]+?)}}', replaceValues, theme)
with ZipFile('output/temp.zip', 'w') as accentZip:
accentZip.writestr('properties.xml', result)
flavor_zip.write('output/temp.zip', 'mixplorer-catppuccin-' + flavor.name + '-' + accent.name + '.mit')
# remove temporary file
os.remove("output/temp.zip")