-
Notifications
You must be signed in to change notification settings - Fork 10
/
scaffold.py
41 lines (33 loc) · 1.09 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
# -*- coding: utf-8 -*-
import argparse
import os
from pprint import pprint
import shutil
import sys
import lib.item_utils as tu
import lib.string_utils as su
# input
parser = argparse.ArgumentParser()
parser.add_argument('-config', dest="CONFIG_FILE", default="config-sample.yml", help="Config file")
parser.add_argument('-overwrite', dest="OVERWRITE", action="store_true", help="Overwrite existing folder?")
a = parser.parse_args()
config = tu.loadConfig(a.CONFIG_FILE)
appName = config["name"]
src = "apps/template"
dest = "apps/%s" % appName
# indexFilenameTemplate = src + "/index.html"
# indexFilename = dest + "/index.html"
#
if os.path.isdir(dest) and not a.OVERWRITE:
print("%s already exists. Delete manually or run with -ovewrite flag. Overwriting will remove all assets and changes you made to the app folder." % dest)
sys.exit()
if os.path.isdir(dest):
print("Deleting existing folder %s..." % dest)
shutil.rmtree(dest)
try:
shutil.copytree(src, dest)
except OSError as exc:
if exc.errno == errno.ENOTDIR:
shutil.copy(src, dest)
else: raise
print("Done.")