Skip to content

Commit 38d60fe

Browse files
committed
Create output directory if not existing.
1 parent 6d2fe84 commit 38d60fe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

convert.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ def convert(def_path, caffemodel_path, data_output_path, code_output_path, phase
2929
if caffemodel_path is not None:
3030
data = transformer.transform_data()
3131
print_stderr('Saving data...')
32+
# create directory if not existing
33+
dirname = os.path.dirname(data_output_path)
34+
if not os.path.exists(dirname):
35+
os.makedirs(dirname)
3236
with open(data_output_path, 'wb') as data_out:
3337
np.save(data_out, data)
3438
if code_output_path:
3539
print_stderr('Saving source...')
40+
# create directory if not existing
41+
dirname = os.path.dirname(code_output_path)
42+
if not os.path.exists(dirname):
43+
os.makedirs(dirname)
3644
with open(code_output_path, 'wb') as src_out:
3745
src_out.write(transformer.transform_source())
3846
print_stderr('Done.')

0 commit comments

Comments
 (0)