-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
mariana.py
51 lines (38 loc) · 1.27 KB
/
mariana.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
47
48
49
50
51
''' Copyright © 2022 mightbesimon.com
All rights reserved.
Material belonging to others may have been
used under Creative Commons Licence or with
explicit or implicit permission.
'''
from lifehacks.colour import Colour
from lifehacks.colour.palette import Mariana
from lifehacks.metaclasses import enum
class ThemeReference:
def __init__(self, filename:str) -> None:
self.filename = filename
def use_themes(self, *themes:enum[Colour]) -> 'ThemeReference':
self.themes = themes
return self
def export_color_theme(self, filename:str) -> 'ThemeReference':
with open(self.filename, 'r') as file:
content = file.read()
content = ( content
.replace(': ', ':')
.replace('\t', '' )
.replace('\n', '' )
)
for theme in self.themes:
for name, colour in theme:
content = content.replace(name, colour.to_hex())
with open(filename, 'w') as file:
file.write(content)
return self
################################################################
####### MAIN STARTS HERE #######
################################################################
if __name__ == '__main__':\
(
ThemeReference(filename='themes/mariana-reference.json')
.use_themes(Mariana)
.export_color_theme(filename='themes/mariana-color-theme.json')
)