forked from ICEI-PUCMinas-PSG-SI-TI/psg-si-2024-02-p3-tiapn-6618100-psg-si-2024-02-p3-tiapn-6618100-TIAPN-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react_template.py
50 lines (43 loc) · 1.34 KB
/
react_template.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
import os
structure = {
"src": {
"frontend": {
"public": ["index.html"],
"src": {
"assets": [],
"components": [],
"pages": [],
"hooks": [],
"contexts": [],
"services": [],
"utils": [],
"App.js": "",
"index.js": ""
},
"package.json": ""
}
}
}
def create_structure(base_path, structure):
"""
Cria a estrutura de diretórios e arquivos.
:param base_path: Caminho base para iniciar a criação.
:param structure: Dicionário que define a estrutura de pastas e arquivos.
"""
for name, content in structure.items():
path = os.path.join(base_path, name)
if isinstance(content, dict):
os.makedirs(path, exist_ok=True)
create_structure(path, content)
elif isinstance(content, list):
os.makedirs(path, exist_ok=True)
for file_name in content:
file_path = os.path.join(path, file_name)
with open(file_path, "w") as f:
f.write("")
else:
with open(path, "w") as f:
f.write(content)
base_path = os.path.join(os.getcwd(), "src")
create_structure(base_path, structure)
print("Done.")