-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_project.py
35 lines (28 loc) · 906 Bytes
/
create_project.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
import argparse
import fileinput
import os
import shutil
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--proj', type=str, help='The project name.')
parser.add_argument('-a', '--app', type=str, help='Name of the first app.')
args = parser.parse_args()
project_name = args.proj
app_name = args.app
cur_dir = os.getcwd()
dst_dir = os.path.join(cur_dir, project_name)
template_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'templates'
)
if os.path.exists(dst_dir) and os.path.isdir(dst_dir):
print(
"A directory with the same name exists! Use another project name."
)
sys.exit(1)
shutil.copytree(template_dir, dst_dir)
shutil.move(
os.path.join(dst_dir, 'app_dir'), os.path.join(dst_dir, app_name)
)
if __name__ == '__main__':
main()