-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscaffold.py
52 lines (40 loc) · 1.07 KB
/
scaffold.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
52
import json
import os
css = f'.container {{\n height: auto;\n}}\n'
root_dir = './src/components'
def make_js(class_name):
js = f'import styles from \'./' + class_name + '.module.scss\'\n'
js += f'\n'
js += f'const {class_name} = () => {{\n'
js += f' return (\n'
js += f' <div className={{styles.container}} />\n'
js += f' );\n'
js += f'}}\n'
js += f'\n'
js += f'export default {class_name};\n'
js += f'\n'
return js
def make_files(path, files):
for name in files:
f = open(f'{path}/{name}.js', 'w+')
f.write(make_js(name))
f.close()
f = open(f'{path}/{name}.module.scss', 'w+')
f.write(css)
f.close()
def process(name, data):
path = f'{root_dir}/{name}'
try:
os.mkdir(path)
except:
pass
for i in data:
if i == 'files':
make_files(path, data[i])
else:
process(f'{name}/{i}', data[i])
if __name__ == '__main__':
f = open('structure.json')
data = json.load(f)
for i in data:
process(i, data[i])