Skip to content

Commit a605b08

Browse files
committed
added option to create destination folder
1 parent 2fd928f commit a605b08

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

install.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import time
77
import codecs
8+
import shutil
89
import argparse
910

1011
# project modules
@@ -100,6 +101,27 @@ def parse_and_encode_ngrams(extracted_it, simstring_dir, cuisty_dir):
100101

101102

102103
def driver(opts):
104+
if not os.path.exists(opts.destination_path):
105+
msg = ('Directory "{}" does not exists; should I create it? [y/N] '
106+
''.format(opts.destination_path))
107+
create = input(msg).lower().strip() == 'y'
108+
if create:
109+
os.mkdir(opts.destination_path)
110+
else:
111+
print('Aborting.')
112+
exit(1)
113+
114+
if len(os.listdir(opts.destination_path)) > 0:
115+
msg = ('Directory "{}" is not empty; should I empty it? [y/N] '
116+
''.format(opts.destination_path))
117+
empty = input(msg).lower().strip() == 'y'
118+
if empty:
119+
shutil.rmtree(opts.destination_path)
120+
os.mkdir(opts.destination_path)
121+
else:
122+
print('Aborting.')
123+
exit(1)
124+
103125
if opts.normalize_unicode:
104126
try:
105127
unidecode

0 commit comments

Comments
 (0)