-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathINSTALL.py
executable file
·57 lines (48 loc) · 1.87 KB
/
INSTALL.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
53
54
55
56
57
#!/usr/bin/env python2.7
# Filename: INSTALL.sh
# Author: LIU Yang
# Create Time: Sat Oct 26 13:15:39 HKT 2013
# License: LGPL v2.0+
# Contact Me: [email protected]
'''Simple install script of newycm_extra_conf.py
'''
# TODO (LIU Yang) Is there any installation tool for plain files?
# It should be tiny and neat.
import argparse
import os
import subprocess
from newycm_extra_conf import DICT_FNAME_IN, DICT_LIBS_FNAME
import shutil
PARSER = argparse.ArgumentParser()
PARSER.add_argument('--template_path', action='store', dest='tpath',
default='$HOME/Templates',
help='Where do you want to install the templates?')
PARSER.add_argument('--bin_path', action='store', dest='bpath',
default='$HOME/bin',
help='Where do you want to install the executable?')
def main():
'''Main process'''
args = PARSER.parse_args()
# Parse shell environ variables, e.g., $HOME
tpath = subprocess.check_output('echo '+args.tpath, shell=True).rstrip()
bpath = subprocess.check_output('echo '+args.bpath, shell=True).rstrip()
if not os.path.exists(tpath):
os.makedirs(tpath)
if not os.path.exists(bpath):
os.makedirs(bpath)
templates = DICT_FNAME_IN.values() + DICT_LIBS_FNAME.values()
for template in templates:
if not os.path.exists(os.path.join(tpath, template)):
print("INSTALL {:20s} ==> {}".format(template, tpath))
shutil.copy(template, tpath)
# TODO (LIU Yang) Check if it needs update, behaviors like 'cp -u'
else:
print("{} already exists".format(template))
fname_out = 'newycm_extra_conf.py'
if not os.path.exists(os.path.join(bpath, fname_out)):
print("INSTALL {:20s} ==> {}".format(fname_out, bpath))
shutil.copy(fname_out, bpath)
else:
print("{} already exists".format(fname_out))
if __name__ == '__main__':
main()