Skip to content

Commit e6627ea

Browse files
author
Denis Druzhinin
committed
Add color scheme support to build.py
1 parent f0b10b2 commit e6627ea

File tree

2 files changed

+36
-48
lines changed

2 files changed

+36
-48
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/build/
2+
/.vs/
23
*.zip
34
*.sublime-workspace

build.py

+35-48
Original file line numberDiff line numberDiff line change
@@ -10,82 +10,69 @@
1010
PROJECT_NAME = 'diva-redux'
1111
RELEASE = False
1212

13-
NOW = time.strftime('%Y-%m%d-%H%M')
1413
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
14+
NOW = time.strftime('%Y-%m%d-%H%M')
1515
ZIP_NAME = '%s-%s' % (PROJECT_NAME, NOW)
1616

17-
BUILD_PATH = os.path.join(BASE_DIR, 'build')
18-
REDUX_PATH = os.path.join(BUILD_PATH, 'Redux')
19-
SCRIPTS_PATH = os.path.join(REDUX_PATH, 'Scripts')
20-
SCHEMES_PATH = os.path.join(BASE_DIR, 'color_schemes')
21-
22-
color_schemes = []
23-
24-
25-
for root, _, files in os.walk(SCHEMES_PATH):
26-
for filename in files:
27-
full_path = os.path.join(root, filename)
28-
color_schemes.append(full_path)
29-
30-
31-
for scheme in color_schemes:
32-
with open(scheme, 'r') as f:
33-
color_scheme = f.read()
34-
35-
36-
config = {'label_font': 'RopaSans-Italic',
37-
'label_font_size': '12.00',
38-
'label_small_font': 'Viga-Regular',
39-
'label_small_font_size': '10.00',
40-
'display_font': 'RopaSans-Italic',
41-
'display_font_size': '13.00',
42-
'button_font': 'RopaSans-Italic',
43-
'button_font_size': '13.00',
44-
'slider_head_size': '2.00',
45-
'slider_sensitivity': '0.20',
46-
'redux_color_scheme': color_scheme,
47-
}
48-
49-
garbage = ['(?!#FX.)[#].*', '^[ \t]+', '[ \t]+$', ' +', '^\n']
17+
THEMES = {'Redux': f'{BASE_DIR}/color_schemes/default.txt',
18+
'Redux Gray': f'{BASE_DIR}/color_schemes/gray.txt'}
5019

5120

52-
def main():
21+
for theme in THEMES:
5322
try:
54-
shutil.rmtree(REDUX_PATH)
23+
shutil.rmtree(f'{BASE_DIR}/build/{theme}')
5524
except Exception as e:
5625
print(e)
5726

27+
28+
for theme in THEMES:
5829
try:
59-
os.makedirs(REDUX_PATH)
30+
os.makedirs(f'{BASE_DIR}/build/{theme}')
6031
except Exception as e:
6132
print(e)
6233
finally:
63-
shutil.copytree(os.path.join(BASE_DIR, 'scripts'), SCRIPTS_PATH)
34+
shutil.copytree(f'{BASE_DIR}/scripts', f'{BASE_DIR}/build/{theme}/Scripts')
35+
36+
37+
for theme in THEMES:
38+
with open(THEMES[theme], 'r') as f:
39+
color_scheme = f.read()
40+
41+
config = {'redux_color_scheme': color_scheme,
42+
'label_font': 'RopaSans-Italic',
43+
'label_font_size': '12.00',
44+
'label_small_font': 'Viga-Regular',
45+
'label_small_font_size': '10.00',
46+
'display_font': 'RopaSans-Italic',
47+
'display_font_size': '13.00',
48+
'button_font': 'RopaSans-Italic',
49+
'button_font_size': '13.00',
50+
'slider_head_size': '2.00',
51+
'slider_sensitivity': '0.20'}
52+
53+
garbage = ['(?!#FX.)[#].*', '^[ \t]+', '[ \t]+$', ' +', '^\n']
6454

6555
scripts = []
6656

67-
for root, _, files in os.walk(SCRIPTS_PATH):
57+
for root, _, files in os.walk(f'{BASE_DIR}/build/{theme}/Scripts'):
6858
for filename in files:
6959
full_path = os.path.join(root, filename)
7060
scripts.append(full_path)
7161

7262
for line in fileinput.FileInput(scripts, inplace=1):
73-
for i, _ in enumerate(garbage):
74-
line = re.sub(garbage[i], '', line)
75-
7663
for key in config:
7764
regex_string = r'\b(%s)\b' % key
7865
line = re.sub(regex_string, config[key], line)
7966

80-
print(line, end='')
81-
82-
if RELEASE:
83-
shutil.make_archive(os.path.join(BASE_DIR, ZIP_NAME), 'zip', BUILD_PATH)
67+
for i, _ in enumerate(garbage):
68+
line = re.sub(garbage[i], '', line)
8469

85-
winsound.Beep(2000, 100)
70+
print(line, end='')
8671

8772

8873
if __name__ == '__main__':
8974
if len(sys.argv) > 1:
9075
RELEASE = True
91-
main()
76+
shutil.make_archive(f'{BASE_DIR}/{ZIP_NAME}', 'zip', f'{BASE_DIR}/build')
77+
78+
winsound.Beep(2000, 100)

0 commit comments

Comments
 (0)