-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_file.py
More file actions
45 lines (37 loc) · 933 Bytes
/
add_file.py
File metadata and controls
45 lines (37 loc) · 933 Bytes
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
import os
root_path = os.getcwd()
directory_list = [
'dbconnector',
'exceptions',
'helper',
'route',
'session',
'template_engine',
'view',
'wsgi_adapter'
]
children = {'name': '__init__.py', 'children': None, 'type': 'file'}
dir_map = [{
'name': 'PyFwk',
'children': [{
'name': directory,
'type': 'dir',
'children': [children]
} for directory in directory_list] + [children],
'type': 'dir'
}]
def create(path, kind):
if kind == 'dir':
os.mkdir(path)
else:
open(path, 'w').close()
def gen_project(parent_path, map_obj):
for line in map_obj:
path = os.path.join(parent_path, line['name'])
create(path, line['type'])
if line['children']:
gen_project(path, line['children'])
def main():
gen_project(root_path, dir_map)
if __name__ == '__main__':
main()